Platform Specific Headers

There is often a need to provide platform specific macros that allow a developer access to low-level platform functionality.

The benefits of having the C library provide these low-level macros are as follows:

The problems with having the C library provide these low-level macros are as follows:

The benefits of having GCC provide the header:

The problems with having the C library provide these low-level macros are as follows:

The following guidelines help in deciding wether the header should live in GCC or GLIBC:

The general solution for providing low-level macros is to export them as follows:

The easiest way to ship a header is to add it to the sysdep_headers variable, for example, the combination of Linux-specific headers on PowerPC could be provided like this:

--- a/sysdeps/powerpc/Makefile
+++ b/sysdeps/powerpc/Makefile
@@ -26,3 +32,5 @@ gen-as-const-headers += rtld-global-offsets.sym
 # get offset to __locale_struct.__ctype_tolower
 gen-as-const-headers += locale-defines.sym
 endif
+
+sysdeps_header += sys/platform/ppc.h

--- a/sysdeps/unix/sysv/linux/powerpc/Makefile
+++ b/sysdeps/unix/sysv/linux/powerpc/Makefile
@@ -15,3 +15,5 @@ endif
 ifeq ($(subdir),elf)
 sysdep_routines += dl-vdso
 endif
+
+sysdep_headers += bits/ppc.h

Then ensure that you have checked in a sys/platform/ppc.h header underneath your target platform sysdeps directory e.g., sysdeps/powerpc/sys/platform/ppc.h and a bits/ppc.h underneath your target OS specific sysdeps directory e.g., sysdeps/unix/sysv/linux/powerpc/bits/ppc.h.

None: PlatformHeaders (last edited 2015-07-03 04:10:51 by CarlosODonell)