Skip to content

Commit

Permalink
Merge branch 'trunksvn'
Browse files Browse the repository at this point in the history
  • Loading branch information
DevSolar committed May 29, 2020
2 parents 670ea40 + 9a82f95 commit 0b1e738
Show file tree
Hide file tree
Showing 10 changed files with 234 additions and 215 deletions.
16 changes: 10 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ set( PDCLIB_SOURCES
platform/example/functions/time/time.c
platform/example/functions/time/timespec_get.c

functions/_tzcode/_PDCLIB_tzparse.c
functions/_tzcode/_PDCLIB_tzload.c
#functions/_tzcode/_PDCLIB_tzparse.c
#functions/_tzcode/_PDCLIB_tzload.c

functions/_PDCLIB/assert.c
functions/_PDCLIB/errno.c
Expand Down Expand Up @@ -306,7 +306,7 @@ set( PDCLIB_PRIVATE_HEADERS
include/pdclib/_PDCLIB_glue.h
include/pdclib/_PDCLIB_int.h
include/pdclib/_PDCLIB_lib_ext1.h
include/pdclib/_PDCLIB_tzcode.h
#include/pdclib/_PDCLIB_tzcode.h
platform/example/include/pdclib/_PDCLIB_config.h
)

Expand All @@ -322,7 +322,7 @@ add_library( pdclib SHARED ${PDCLIB_SOURCES} $<TARGET_OBJECTS:_dlmalloc> ${PDC
add_library( pdclibs STATIC ${PDCLIB_SOURCES} $<TARGET_OBJECTS:_dlmallocs> ${PDCLIB_HEADERS} ${PDCLIB_PRIVATE_HEADERS} )

# The example implementation makes use of pthread. We use CMake facilities
# to locate the pthread library and header.
# to locate the pthread library for linking.
set( CMAKE_THREAD_PREFER_PTHREAD 1 )
set( THREADS_PREFER_PTHREAD_FLAG 1 )
find_package( Threads )
Expand Down Expand Up @@ -356,22 +356,26 @@ elseif( MSVC )
set( FLAGS "/W4 /D_CRT_SECURE_NO_WARNINGS /wd4996" )
endif()

# Optionally, use C++ compiler instead of C compiler.
if ( AS_CXX )
set_source_files_properties( ${PDCLIB_SOURCES} ${PDCLIB_HEADERS} ${PDCLIB_PRIVATE_HEADERS} PROPERTIES LANGUAGE CXX )
endif()

# Optionally, make TESTCASE( NO_TESTDRIVER ) succeed instead of fail.
if ( IGNORE_NO_TESTDRIVER )
string( APPEND FLAGS " -DNO_TESTDRIVER=1" )
endif()

# Setting symbol visibility (_PDCLIB_LOCAL / _PDCLIB_PUBLIC configuration
# in _PDCLIB_config.h)
set_property( TARGET pdclib APPEND_STRING PROPERTY COMPILE_FLAGS "-D_PDCLIB_BUILD ${FLAGS}" )
set_property( TARGET pdclibs APPEND_STRING PROPERTY COMPILE_FLAGS "-D_PDCLIB_STATIC_DEFINE ${FLAGS}" )

# On Windows, both a dynamic .dll and a static .a library require their own
# respective .lib file, which is why the static library has its distinctive
# name pdclibs.a (note the "s").
# On Unix-like OS', we can have both .so and .a with the same base
# name, so we do away with the "s" suffix.
# On Unix-like OS' (and Cygwin), we can have both .so and .a with the same
# base name, so we do away with the "s" suffix.
if ( UNIX )
set_target_properties( pdclibs PROPERTIES OUTPUT_NAME pdclib )
endif()
Expand Down
12 changes: 6 additions & 6 deletions auxiliary/pthread/pthread_readout.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
/* For _PDCLIB_time -> reconstructing struct _PDCLIB_timespec */
#include "_PDCLIB_config.h"

#define symbol2value( x ) #x
#define symbol2string( x ) symbol2value( x )
#define symbol2string( x ) #x
#define value2string( x ) symbol2string( x )

struct _PDCLIB_timespec
{
Expand Down Expand Up @@ -167,15 +167,15 @@ int main( int argc, char * argv[] )

/* once_flag init */
#ifdef __CYGWIN__
printf( "#define _PDCLIB_ONCE_FLAG_INIT { %s, 0 }\n", symbol2string( PTHREAD_MUTEX_INITIALIZER ) );
printf( "#define _PDCLIB_ONCE_FLAG_INIT { %s, 0 }\n", value2string( PTHREAD_MUTEX_INITIALIZER ) );
#else
printf( "#define _PDCLIB_ONCE_FLAG_INIT %s\n", symbol2string( PTHREAD_ONCE_INIT ) );
printf( "#define _PDCLIB_ONCE_FLAG_INIT %s\n", value2string( PTHREAD_ONCE_INIT ) );
#endif

#ifdef __CYGWIN__
printf( "#define _PDCLIB_RECURSIVE_MUTEX_INIT %s\n", symbol2string( PTHREAD_MUTEX_INITIALIZER ) );
printf( "#define _PDCLIB_RECURSIVE_MUTEX_INIT %s\n", value2string( PTHREAD_MUTEX_INITIALIZER ) );
#else
printf( "#define _PDCLIB_RECURSIVE_MUTEX_INIT %s\n", symbol2value( PTHREAD_MUTEX_INITIALIZER ) );
printf( "#define _PDCLIB_RECURSIVE_MUTEX_INIT %s\n", symbol2string( PTHREAD_MUTEX_INITIALIZER ) );
#endif

/* _PDCLIB_TSS_DTOR_ITERATIONS */
Expand Down
21 changes: 20 additions & 1 deletion functions/_tzcode/_PDCLIB_tzload.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,26 @@

#ifndef REGTEST

#define _DEFAULT_SOURCE
/* This implements the following parts from tzcode2019c:
- tzload() (as _PDCLIB_tzload()) -- load timezone definition from data file
It uses helper functions also present in tzcode2019c:
- differ_by_repeat() -- whether two timestamps differ by exactly 400 years
- typesequiv() -- whether two timezone types are identical
It uses helper functions not present in / changed from tzcode2019c:
- tzread_val() Higher-level abstraction of detzcode() / detzcode64()
- tzread_time() Higher-level abstraction of detzcode() / detzcode64()
- tzopen() First part of tzloadbody() -- path resolution, open file
- tzread_data() Second part of tzloadbody() -- read main data
- tzread_extension() Third part of tzloadbody() -- read POSIX extension line
- tzdata_complete() Fourth part of tzloadbody() -- inferred information
- free_tzdata() Deallocate struct _PDCLIB_timezone (struct state)
*/

#include "pdclib/_PDCLIB_tzcode.h"
#include "pdclib/_PDCLIB_config.h"
Expand Down
2 changes: 1 addition & 1 deletion functions/inttypes/strtoimax.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ int main( void )
TESTCASE( strtoimax( "0Xa1", NULL, 0 ) == 161 );
/* proper handling of border case: 0x followed by non-hexdigit */
TESTCASE( strtoimax( tricky, &endptr, 0 ) == 0 );
TESTCASE( endptr == tricky + 2 );
TESTCASE_NOREG( endptr == tricky + 2 );
/* proper handling of border case: 0 followed by non-octdigit */
TESTCASE( strtoimax( tricky, &endptr, 8 ) == 0 );
TESTCASE( endptr == tricky + 2 );
Expand Down
2 changes: 1 addition & 1 deletion functions/inttypes/strtoumax.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ int main( void )
TESTCASE( strtoumax( "0Xa1", NULL, 0 ) == 161 );
/* proper handling of border case: 0x followed by non-hexdigit */
TESTCASE( strtoumax( tricky, &endptr, 0 ) == 0 );
TESTCASE( endptr == tricky + 2 );
TESTCASE_NOREG( endptr == tricky + 2 );
/* proper handling of border case: 0 followed by non-octdigit */
TESTCASE( strtoumax( tricky, &endptr, 8 ) == 0 );
TESTCASE( endptr == tricky + 2 );
Expand Down
4 changes: 2 additions & 2 deletions functions/locale/setlocale.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ char * setlocale( int category, const char * locale )
locale = _PDCLIB_default_locale( category );
}

if ( getenv( _PDCLIB_symbol2string( _PDCLIB_LOCALE_PATH_ENV ) ) != NULL )
if ( getenv( _PDCLIB_value2string( _PDCLIB_LOCALE_PATH_ENV ) ) != NULL )
{
path = getenv( _PDCLIB_symbol2string( _PDCLIB_LOCALE_PATH_ENV ) );
path = getenv( _PDCLIB_value2string( _PDCLIB_LOCALE_PATH_ENV ) );
}

/* We have to do this in two runs. As we might be facing LC_ALL, we
Expand Down
4 changes: 2 additions & 2 deletions include/assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ _PDCLIB_PUBLIC void _PDCLIB_assert89( const char * const );
: _PDCLIB_assert99( "Assertion failed: " #expression \
", function ", __func__, \
", file " __FILE__ \
", line " _PDCLIB_symbol2string( __LINE__ ) \
", line " _PDCLIB_value2string( __LINE__ ) \
"." _PDCLIB_endl ) )
#else
#define assert( expression ) ( ( expression ) ? (void) 0 \
: _PDCLIB_assert89( "Assertion failed: " #expression \
", file " __FILE__ \
", line " _PDCLIB_symbol2string( __LINE__ ) \
", line " _PDCLIB_value2string( __LINE__ ) \
"." _PDCLIB_endl ) )
#endif
#endif
Expand Down
Loading

0 comments on commit 0b1e738

Please sign in to comment.