jaulib v1.3.0
Jau Support Library (C++, Java, ..)
Macros | Functions
test_os_posix_libc_macros.cpp File Reference
#include <sys/param.h>
#include <unistd.h>
#include <climits>
#include <jau/test/catch2_ext.hpp>
#include <jau/basic_types.hpp>
#include <cstring>
Include dependency graph for test_os_posix_libc_macros.cpp:

Go to the source code of this file.

Macros

#define COND_CODE(macro, code)
 
#define MACRO_STRINGIFY(item)   "" #item
 
#define PRINT_COND(macro)
 

Functions

int my_strcmp (const char *, const char *)
 
void print_libc ()
 
void print_unix_std ()
 
int printf (const char *format,...)
 Operating Systems predefined macros. More...
 
static int sizeof_time_t ()
 Resembling the GNU/Linux bits/types.h, documenting whether time_t is 32-bit (arm-32) or 64-bit (arm-64, x86_64, ..). More...
 
static int sizeof_tv_nsec ()
 Resembling the GNU/Linux bits/types.h, documenting whether tv_nsec of struct timespec is 32-bit (arm-32) or 64-bit (arm-64, x86_64, ..). More...
 
 TEST_CASE ("Standard C Library 01.01", "[libc]")
 
 TEST_CASE ("Unix StandardsTest 01.00", "[unix][posix]")
 

Macro Definition Documentation

◆ MACRO_STRINGIFY

#define MACRO_STRINGIFY (   item)    "" #item

Definition at line 68 of file test_os_posix_libc_macros.cpp.

◆ COND_CODE

#define COND_CODE (   macro,
  code 
)
Value:
do { \
if (my_strcmp("" #macro, MACRO_STRINGIFY(macro))) { \
(code); \
} \
} while (0)
int my_strcmp(const char *, const char *)
#define MACRO_STRINGIFY(item)

Definition at line 69 of file test_os_posix_libc_macros.cpp.

◆ PRINT_COND

#define PRINT_COND (   macro)
Value:
do { \
if (my_strcmp("" #macro, MACRO_STRINGIFY(macro))) { \
printf("- %s\t%s\n", #macro, MACRO_STRINGIFY(macro)); \
} else { \
printf("- %s\t-\n", #macro); \
} \
} while (0)

Definition at line 76 of file test_os_posix_libc_macros.cpp.

Function Documentation

◆ printf()

int printf ( const char *  format,
  ... 
)

Operating Systems predefined macros.

  • BSD included from <sys/param.h> Unix standards require the existence macros in the <unistd.h> header file. GNU glibc

GLIBC macros have to be included from the <features.h> header file. Include <limits.h> header file instead, which included <features.h> on GLIBC (see e.g. paragraph 4/6 in ISO/IEC 9899:1999). glibc 1.3.4 Feature Test Macros _FILE_OFFSET_BITS

  • available if _POSIX_C_SOURCE >= 200112L
  • _FILE_OFFSET_BITS == 64 implies using all 64-bit file-function and -type variants on 32-bit platforms
  • _FILE_OFFSET_BITS == 64 has no effect on 64-bit platforms, already using the 64-bit variants
  • _FILE_OFFSET_BITS is favored over _LARGEFILE64_SOURCE

_TIME_BITS

  • introduced in glibc 2.34, tackling year 2038 issue
  • _TIME_BITS available for Linux with kernel >= 5.1
  • _TIME_BITS == 64 requires _FILE_OFFSET_BITS to be 64 as well

glibc D.2.1 64-bit time symbol handling in the GNU C Library __TIMESIZE == 64 uses 64-bit time_t version

Examples
test_cow_darray_perf01.cpp, and test_cow_iterator_01.cpp.
Here is the caller graph for this function:

◆ my_strcmp()

int my_strcmp ( const char *  s1,
const char *  s2 
)

Definition at line 167 of file test_os_posix_libc_macros.cpp.

◆ print_unix_std()

void print_unix_std ( )

Definition at line 85 of file test_os_posix_libc_macros.cpp.

Here is the caller graph for this function:

◆ print_libc()

void print_libc ( )

Definition at line 131 of file test_os_posix_libc_macros.cpp.

Here is the caller graph for this function:

◆ sizeof_time_t()

static int sizeof_time_t ( )
static

Resembling the GNU/Linux bits/types.h, documenting whether time_t is 32-bit (arm-32) or 64-bit (arm-64, x86_64, ..).

Definition at line 175 of file test_os_posix_libc_macros.cpp.

Here is the caller graph for this function:

◆ sizeof_tv_nsec()

static int sizeof_tv_nsec ( )
static

Resembling the GNU/Linux bits/types.h, documenting whether tv_nsec of struct timespec is 32-bit (arm-32) or 64-bit (arm-64, x86_64, ..).

Definition at line 194 of file test_os_posix_libc_macros.cpp.

Here is the caller graph for this function:

◆ TEST_CASE() [1/2]

TEST_CASE ( "Unix StandardsTest 01.00"  ,
""  [unix][posix] 
)

Definition at line 206 of file test_os_posix_libc_macros.cpp.

◆ TEST_CASE() [2/2]

TEST_CASE ( "Standard C Library 01.01"  ,
""  [libc] 
)

Definition at line 226 of file test_os_posix_libc_macros.cpp.