added macro to fetch the address of errno

This commit is contained in:
Perry Kivolowitz 2023-02-03 10:22:27 -06:00
parent e73fac71b5
commit b6b5b96c56
7 changed files with 73 additions and 2 deletions

View file

@ -185,10 +185,21 @@ library, use this macro in this way:
`CRT strlen`
An underscore is prepended.
An underscore is prepended on the Mac.
## Declaring `main()`
Put `MAIN` on a line by itself. Notice there is no colon.
An underscore is prepended.
An underscore is prepended on the Mac.
## `errno`
The externally defined `errno` is accessed via a CRT function which
isn't seen when coding in C and C++. The function is named differently
on Mac versus Linux. To get the address of `errno` use:
`ERRNO_ADDR`
This macro makes the correct CRT call and leaves the address of `errno`
in `x0`.

Binary file not shown.

View file

@ -75,6 +75,18 @@ main:
#endif
.endm
/* Fetching the address of the externally defined errno is quite
different on Apple and Linux. This macro leaves the address of
errno in x0.
*/
.macro ERRNO_ADDR
#if defined(__APPLE__)
bl ___error
#else
bl __errno_location
#endif
.endm
.macro CRT label
#if defined(__APPLE__)
bl _\label

View file

@ -75,6 +75,18 @@ main:
#endif
.endm
/* Fetching the address of the externally defined errno is quite
different on Apple and Linux. This macro leaves the address of
errno in x0.
*/
.macro ERRNO_ADDR
#if defined(__APPLE__)
bl ___error
#else
bl __errno_location
#endif
.endm
.macro CRT label
#if defined(__APPLE__)
bl _\label

View file

@ -75,6 +75,18 @@ main:
#endif
.endm
/* Fetching the address of the externally defined errno is quite
different on Apple and Linux. This macro leaves the address of
errno in x0.
*/
.macro ERRNO_ADDR
#if defined(__APPLE__)
bl ___error
#else
bl __errno_location
#endif
.endm
.macro CRT label
#if defined(__APPLE__)
bl _\label

View file

@ -75,6 +75,18 @@ main:
#endif
.endm
/* Fetching the address of the externally defined errno is quite
different on Apple and Linux. This macro leaves the address of
errno in x0.
*/
.macro ERRNO_ADDR
#if defined(__APPLE__)
bl ___error
#else
bl __errno_location
#endif
.endm
.macro CRT label
#if defined(__APPLE__)
bl _\label

View file

@ -75,6 +75,18 @@ main:
#endif
.endm
/* Fetching the address of the externally defined errno is quite
different on Apple and Linux. This macro leaves the address of
errno in x0.
*/
.macro ERRNO_ADDR
#if defined(__APPLE__)
bl ___error
#else
bl __errno_location
#endif
.endm
.macro CRT label
#if defined(__APPLE__)
bl _\label