Remove unused types and definitions from abstraction layer

Signed-off-by: Jeroen Koekkoek <jeroen@koekkoek.nl>
This commit is contained in:
Jeroen Koekkoek 2019-01-02 20:01:51 +01:00
parent e25656a4c5
commit 5835a85dc2
27 changed files with 51 additions and 453 deletions

View file

@ -305,9 +305,9 @@ int spdp_write (struct participant *pp)
os_gethostname(node, sizeof(node)-1);
node[sizeof(node)-1] = '\0';
size = strlen(node) + strlen(OSPL_VERSION_STR) + strlen(OSPL_HOST_STR) + strlen(OSPL_TARGET_STR) + 4; /* + ///'\0' */
size = strlen(node) + strlen(OS_VERSION) + strlen(OS_HOST_NAME) + strlen(OS_TARGET_NAME) + 4; /* + ///'\0' */
ps.prismtech_participant_version_info.internals = os_malloc(size);
(void) snprintf(ps.prismtech_participant_version_info.internals, size, "%s/%s/%s/%s", node, OSPL_VERSION_STR, OSPL_HOST_STR, OSPL_TARGET_STR);
(void) snprintf(ps.prismtech_participant_version_info.internals, size, "%s/%s/%s/%s", node, OS_VERSION, OS_HOST_NAME, OS_TARGET_NAME);
DDS_TRACE("spdp_write(%x:%x:%x:%x) - internals: %s\n", PGUID (pp->e.guid), ps.prismtech_participant_version_info.internals);
}

View file

@ -511,11 +511,7 @@ int os_sockWaitsetNextEvent (os_sockWaitsetCtx ctx, ddsi_tran_conn_t * conn)
#ifndef _WIN32
#ifndef __VXWORKS__
#if defined (AIX) || defined (__Lynx__) || defined (__QNX__)
#include <fcntl.h>
#elif ! defined(INTEGRITY)
#include <sys/fcntl.h>
#endif
#endif /* __VXWORKS__ */
#ifndef _WRS_KERNEL

View file

@ -11,7 +11,9 @@
#
include(CheckCSourceCompiles)
include(CheckLibraryExists)
include(CheckTypeSize)
include(GenerateExportHeader)
include(TestBigEndian)
set(sources
src/os_atomics.c
@ -93,6 +95,15 @@ if(${CMAKE_C_COMPILER_ID} STREQUAL "SunPro")
target_compile_definitions(OSAPI PRIVATE -KPIC)
endif()
# Determine if platform is big or little endian.
test_big_endian(BIG_ENDIAN)
if(BIG_ENDIAN)
set(OS_ENDIANNESS_CODE "#define OS_ENDIANNESS OS_BIG_ENDIAN")
else()
set(OS_ENDIANNESS_CODE "#define OS_ENDIANNESS OS_LITTLE_ENDIAN")
endif()
# Determine if platform is 32 or 64 bit.
check_type_size("void*" OS_SIZEOF_VOID_P BUILTIN_TYPES_ONLY LANGUAGE C)
configure_file("cmake/os_project.h.in" "include/os/os_project.h")
target_sources(OSAPI PRIVATE "include/os/os_project.h")

View file

@ -12,6 +12,16 @@
#ifndef OS_PROJECT_H
#define OS_PROJECT_H
/* Set OS_ENDIANNESS to OS_BIG_ENDIAN or OS_LITTLE_ENDIAN */
@OS_ENDIANNESS_CODE@
/* Sets OS_SIZEOF_VOID_P to sizeof(void*) */
@OS_SIZEOF_VOID_P_CODE@
#if (OS_SIZEOF_VOID_P == 8)
#define OS_64BIT
#endif
#define OS_VERSION "@CycloneDDS_VERSION@"
#define OS_VERSION_MAJOR @CycloneDDS_VERSION_MAJOR@
#define OS_VERSION_MINOR @CycloneDDS_VERSION_MINOR@
@ -22,4 +32,7 @@
#define OS_PROJECT_NAME_NOSPACE "@CMAKE_PROJECT_NAME@"
#define OS_PROJECT_NAME "@CMAKE_PROJECT_NAME@"
#define OS_HOST_NAME "@CMAKE_HOST_SYSTEM_NAME@"
#define OS_TARGET_NAME "@CMAKE_SYSTEM_NAME@"
#endif /* OS_PROJECT_H */

View file

@ -29,27 +29,9 @@ extern "C" {
#endif
#define OS_DARWIN 1
#define OS_SOCKET_USE_FCNTL 1
#define OS_SOCKET_USE_IOCTL 0
#define OS_HAS_UCONTEXT_T 1
#define OS_FILESEPCHAR '/'
#define OS_HAS_NO_SET_NAME_PRCTL 1
#if __DARWIN_BYTE_ORDER == __DARWIN_LITTLE_ENDIAN
#define OS_ENDIANNESS OS_LITTLE_ENDIAN
#else
#define OS_ENDIANNESS OS_BIG_ENDIAN
#endif
#ifdef _LP64
#define OS_64BIT
#endif
typedef double os_timeReal;
typedef int os_timeSec;
typedef uid_t os_uid;
typedef gid_t os_gid;
typedef mode_t os_mode_t;
typedef pid_t os_procId;
#define PRIprocId "d"

View file

@ -29,23 +29,9 @@ extern "C" {
#endif
#define OS_LINUX 1
#define OS_SOCKET_USE_FCNTL 1
#define OS_SOCKET_USE_IOCTL 0
#define OS_HAS_UCONTEXT_T 1
#define OS_FILESEPCHAR '/'
#define OS_HAS_NO_SET_NAME_PRCTL 1
#define OS_ENDIANNESS OS_LITTLE_ENDIAN
#ifdef _LP64
#define OS_64BIT
#endif
typedef double os_timeReal;
typedef int os_timeSec;
typedef uid_t os_uid;
typedef gid_t os_gid;
typedef mode_t os_mode_t;
typedef pid_t os_procId;
#define PRIprocId "d"

View file

@ -12,6 +12,7 @@
#ifndef OS_H
#define OS_H
#include "os/os_project.h"
#include "os/osapi_export.h"
#include "os_public.h"
@ -21,22 +22,10 @@
#include "vxworks/os_platform.h"
#elif __sun == 1
#include "solaris/os_platform.h"
#elif defined(__INTEGRITY)
#include "integrity/os_platform.h"
#elif __PikeOS__ == 1
#include "pikeos3/os_platform.h"
#elif defined(__QNX__)
#include "qnx/os_platform.h"
#elif defined(_MSC_VER)
#ifdef _WIN32_WCE
#include "wince/os_platform.h"
#else
#include "windows/os_platform.h"
#endif
#elif defined __APPLE__
#include "darwin/os_platform.h"
#elif defined __CYGWIN__
#include "cygwin/os_platform.h"
#else
#error "Platform missing from os.h list"
#endif
@ -56,10 +45,4 @@
#include "os_log.h"
#include "os_strlcpy.h"
#define OSPL_VERSION_STR "aap"
#define OSPL_HOST_STR "noot"
#define OSPL_TARGET_STR "mies"
#define OSPL_INNER_REV_STR "wim"
#define OSPL_OUTER_REV_STR "zus"
#endif

View file

@ -46,33 +46,6 @@ extern "C" {
#include "os_atomics_solaris.h"
#endif
#if ! OS_ATOMIC_SUPPORT && defined __INTEGRITY
#include "os_atomics_integrity.h"
#endif
#if ! OS_ATOMIC_SUPPORT && defined __VXWORKS__
#include "os_atomics_vxworks.h"
#endif
#if ! OS_ATOMIC_SUPPORT && defined __GNUC__ && defined __i386
#include "os_atomics_gcc_x86.h"
#endif
#if ! OS_ATOMIC_SUPPORT && \
((defined __GNUC__ && defined __ppc) || \
(defined __vxworks && defined __PPC__))
/* VxWorks uses GCC but removed the __GNUC__ macro ... */
#include "os_atomics_gcc_ppc.h"
#endif
#if ! OS_ATOMIC_SUPPORT && defined __GNUC__ && defined __sparc__
#include "os_atomics_gcc_sparc.h"
#endif
#if ! OS_ATOMIC_SUPPORT && defined __GNUC__ && defined __arm__
#include "os_atomics_gcc_arm.h"
#endif
#if ! OS_ATOMIC_SUPPORT
#error "No support for atomic operations on this platform"
#endif

View file

@ -18,21 +18,6 @@
#if OS_ENDIANNESS != OS_LITTLE_ENDIAN && OS_ENDIANNESS != OS_BIG_ENDIAN
#error "OS_ENDIANNESS not set correctly"
#endif
#ifndef OS_HAS_UCONTEXT_T
#error "OS_HAS_UCONTEXT_T not set"
#endif
#ifndef OS_SOCKET_USE_FCNTL
#error "OS_SOCKET_USE_FCNTL must be defined for this platform."
#endif
#ifndef OS_SOCKET_USE_IOCTL
#error "OS_SOCKET_USE_IOCTL must be defined for this platform."
#endif
#if (OS_SOCKET_USE_IOCTL == 1) && (OS_SOCKET_USE_FCNTL == 1)
#error "this platform must set only one of OS_SOCKET_USE_IOCTL and OS_SOCKET_USE_FCNTL to 1"
#endif
#ifndef OS_FILESEPCHAR
#error "OS_FILESEPCHAR must be defined for this platform."
#endif
#include "os/os_decl_attributes.h"

View file

@ -46,68 +46,24 @@ extern "C" {
typedef struct sockaddr_in os_sockaddr_in;
typedef struct sockaddr os_sockaddr;
typedef struct sockaddr_storage os_sockaddr_storage;
#ifdef OS_SOCKET_HAS_IPV6
#if (OS_SOCKET_HAS_IPV6 == 0)
struct foo_in6_addr {
unsigned char foo_s6_addr[16];
};
typedef struct foo_in6_addr os_in6_addr;
struct foo_sockaddr_in6 {
os_os_ushort sin6_family;
os_os_ushort sin6_port;
uint32_t sin6_flowinfo;
os_in6_addr sin6_addr;
uint32_t sin6_scope_id;
};
typedef struct foo_sockaddr_in6 os_sockaddr_in6;
struct foo_sockaddr_storage {
#if (OS_SOCKET_HAS_SA_LEN == 1)
os_uchar ss_len;
os_uchar ss_family;
#else
os_os_ushort ss_family;
#endif
/* Below aren't 'real' members. Just here for padding to make it big enough
for any possible IPv6 address. Not that IPv6 works on this OS. */
os_os_ushort sin6_port;
uint32_t sin6_flowinfo;
os_in6_addr sin6_addr;
uint32_t sin6_scope_id;
};
typedef struct foo_sockaddr_storage os_sockaddr_storage;
struct foo_ipv6_mreq {
os_in6_addr ipv6mr_multiaddr;
unsigned int ipv6mr_interface;
};
typedef struct foo_ipv6_mreq os_ipv6_mreq;
#else
#if defined(OS_SOCKET_HAS_IPV6) && OS_SOCKET_HAS_IPV6 == 1
typedef struct ipv6_mreq os_ipv6_mreq;
typedef struct in6_addr os_in6_addr;
typedef struct sockaddr_storage os_sockaddr_storage;
typedef struct sockaddr_in6 os_sockaddr_in6;
#endif
#else
#error OS_SOCKET_HAS_IPV6 not defined
#endif
extern const os_in6_addr os_in6addr_any;
extern const os_in6_addr os_in6addr_loopback;
#endif /* OS_SOCKET_HAS_IPV6 */
#ifndef INET6_ADDRSTRLEN
#define INET6_ADDRSTRLEN 46 /* strlen("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255") + 1 */
#endif
#define INET6_ADDRSTRLEN_EXTENDED (INET6_ADDRSTRLEN + 8) /* + strlen("[]:12345") */
/* The maximum buffersize needed to safely store the output of
* os_sockaddrAddressPortToString or os_sockaddrAddressToString. */
#define OS_SOCKET_MAX_ADDRSTRLEN INET6_ADDRSTRLEN_EXTENDED
#define SD_FLAG_IS_SET(flags, flag) ((((uint32_t)(flags) & (uint32_t)(flag))) != 0U)
#define OS_AF_NULL (-1)

View file

@ -130,7 +130,7 @@ extern "C" {
os_condInit(
_Out_ os_cond *cond,
_In_ os_mutex *mutex)
__nonnull((1,2));
__nonnull_all__;
/** \brief Destroy the condition variable
*/

View file

@ -147,26 +147,6 @@ extern "C" {
_In_ os_threadId threadId,
_Out_opt_ uint32_t *thread_result);
/** \brief Figure out the identity of the current thread
*
* Possible Results:
* - returns the actual length of threadIdentity
*
* Postcondition:
* - \b threadIdentity is ""
* the thread identity could not be determined
* - \b threadIdentity is "<decimal number>" | "0x<hexadecimal number>"
* only the thread numeric identity could be determined
* - \b threadIdentity is "<process name> (<decimal number>)" | "<process name> (0x<hexadecimal number>)"
* the thread name and numeric identity could be determined
*
* \b threadIdentity will not be filled beyond the specified \b threadIdentitySize
*/
OSAPI_EXPORT int32_t
os_threadFigureIdentity(
char *threadIdentity,
uint32_t threadIdentitySize);
/** \brief Get name of current thread
*
* Postcondition:

View file

@ -19,20 +19,18 @@
#endif /* __VXWORKS__ */
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/select.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <sys/select.h>
#ifdef __APPLE__
#include <sys/sockio.h>
#endif /* __APPLE__ */
#include <unistd.h>
#include <ifaddrs.h>
#if defined (__cplusplus)
extern "C" {
#endif

View file

@ -29,23 +29,9 @@ extern "C" {
#endif
#define OS_SOLARIS 1
#define OS_SOCKET_USE_FCNTL 1
#define OS_SOCKET_USE_IOCTL 0
#define OS_HAS_UCONTEXT_T 1
#define OS_FILESEPCHAR '/'
#define OS_HAS_NO_SET_NAME_PRCTL 1
#define OS_ENDIANNESS OS_LITTLE_ENDIAN
#ifdef _LP64
#define OS_64BIT
#endif
typedef double os_timeReal;
typedef int os_timeSec;
typedef uid_t os_uid;
typedef gid_t os_gid;
typedef mode_t os_mode_t;
typedef pid_t os_procId;
#define PRIprocId "d"

View file

@ -98,27 +98,9 @@ extern "C" {
#endif
#define OS_VXWORKS 1
#define OS_SOCKET_USE_FCNTL 0
#define OS_SOCKET_USE_IOCTL 1
#define OS_FILESEPCHAR '/'
#define OS_HAS_NO_SET_NAME_PRCTL 1 /* FIXME: Move to CMake */
#define OS_HAS_UCONTEXT_T 1
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ /* FIXME: Move to CMake */
#define OS_ENDIANNESS OS_BIG_ENDIAN
#else
#define OS_ENDIANNESS OS_LITTLE_ENDIAN
#endif
#if defined(__PPC) || defined(__x86_64__) /* FIXME: Move to CMake */
#define OS_64BIT
#endif
typedef double os_timeReal;
typedef int os_timeSec;
typedef uid_t os_uid;
typedef gid_t os_gid;
typedef mode_t os_mode_t;
#ifdef _WRS_KERNEL
typedef RTP_ID os_procId; /* typedef struct wind_rtp *RTP_ID */
#define PRIprocId "d"

View file

@ -34,28 +34,11 @@ extern "C" {
#endif
#define OS_WIN32 1
#define OS_SOCKET_USE_FCNTL 0
#define OS_SOCKET_USE_IOCTL 1
#define OS_FILESEPCHAR '/'
#define OS_HAS_NO_SET_NAME_PRCTL 1
#define OS_HAS_UCONTEXT_T 0
#ifdef __BIG_ENDIAN
#define OS_ENDIANNESS OS_BIG_ENDIAN
#else
#define OS_ENDIANNESS OS_LITTLE_ENDIAN
#endif
#ifdef _WIN64
#define OS_64BIT
#endif
typedef double os_timeReal;
typedef int os_timeSec;
typedef DWORD os_procId;
#define PRIprocId "u"
/* keep in sync with st_mode field def in struct stat in sys/stat.h */
typedef unsigned short os_mode_t;
typedef SSIZE_T ssize_t;
#include "os/windows/os_platform_socket.h"

View file

@ -19,12 +19,6 @@
extern "C" {
#endif
#define OS_OS_FILESEPCHAR '\\'
#define OS_OS_PATHSEPCHAR ';'
#define OS_OS_EXESUFFIX ".exe"
#define OS_OS_BATSUFFIX ".bat"
#define OS_OS_LIB_LOAD_PATH_VAR "PATH"
#define OS_ROK (_S_IREAD)
#define OS_WOK (_S_IWRITE)
#define OS_XOK (_S_IEXEC)
@ -39,14 +33,6 @@ extern "C" {
#define S_IRWXG 00070
#define S_IRWXO 00007
/* The value _POSIX_PATH_MAX is defined in limits.h, however you have
* to define _POSIX_ during compilation.This again will remove the
* _read, _open and _close prototypes!
*/
#define OS_PATH_MAX 255
typedef HANDLE os_os_dirHandle;
#define MAXHOSTNAMELEN MAX_HOSTNAME_LEN
#if _MSC_VER < 1900

View file

@ -17,32 +17,14 @@ extern "C" {
#endif
typedef struct os_cond {
#ifdef OSPL_STRICT_MEM
/* Used to identify initialized cond when memory is freed -
keep this first in the structure so its so its address is
the same as the os_cond */
uint64_t signature;
#endif
CONDITION_VARIABLE cond;
} os_cond;
typedef struct os_mutex {
#ifdef OSPL_STRICT_MEM
/* Used to identify initialized cond when memory is freed -
keep this first in the structure so its so its address is
the same as the os_cond */
uint64_t signature;
#endif
SRWLOCK lock;
} os_mutex;
typedef struct os_rwlock {
#ifdef OSPL_STRICT_MEM
/* Used to identify initialized cond when memory is freed -
keep this first in the structure so its so its address is
the same as the os_cond */
uint64_t signature;
#endif
SRWLOCK lock;
int state; /* -1: exclusive, 0: free, 1: shared */
} os_rwlock;

View file

@ -24,12 +24,6 @@
#include "os/os.h"
const char *
os_versionString(void)
{
return OSPL_VERSION_STR;
}
#define OSINIT_STATUS_OK 0x80000000u
static os_atomic_uint32_t osinit_status = OS_ATOMIC_UINT32_INIT(0);
static os_mutex init_mutex;

View file

@ -157,10 +157,15 @@ int os_sockaddr_is_unspecified(const os_sockaddr *const sa)
assert(sa != NULL);
if (sa->sa_family == AF_INET6) {
unspec = IN6_IS_ADDR_UNSPECIFIED(&((os_sockaddr_in6 *)sa)->sin6_addr);
} else if (sa->sa_family == AF_INET) {
switch(sa->sa_family) {
#if (OS_SOCKET_HAS_IPV6 == 1)
case AF_INET6:
unspec = IN6_IS_ADDR_UNSPECIFIED(&((os_sockaddr_in6*)sa)->sin6_addr);
break;
#endif
case AF_INET:
unspec = (((os_sockaddr_in *)sa)->sin_addr.s_addr == 0);
break;
}
return unspec;

View file

@ -37,32 +37,3 @@ os_threadAttrInit (
threadAttr->schedPriority = 0;
threadAttr->stackSize = 0;
}
int32_t
os_threadFigureIdentity(char *str, uint32_t size)
{
int32_t cnt;
uintmax_t id;
char *fmt, *ptr, buf[1] = { '\0' };
uint32_t sz;
assert(str != NULL);
assert(size >= 1);
id = os_threadIdToInteger(os_threadIdSelf());
cnt = os_threadGetThreadName(str, size);
if (cnt >= 0) {
fmt = (cnt > 0 ? " 0x%"PRIxMAX : "0x%"PRIxMAX);
if ((uint32_t)cnt < size) {
ptr = str + (uint32_t)cnt;
sz = size - (uint32_t)cnt;
} else {
ptr = buf;
sz = sizeof(buf);
}
cnt += snprintf(ptr, sz, fmt, id);
}
return cnt;
}

View file

@ -18,20 +18,14 @@
#include "os/os.h"
#include <sys/types.h>
#ifndef OSPL_NO_VMEM
#include <sys/mman.h>
#endif
#ifndef PIKEOS_POSIX
#include <sys/wait.h>
#endif
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <sched.h>
#ifndef INTEGRITY
#include <signal.h>
#endif
#include <stdio.h>
#include <pthread.h>

View file

@ -156,6 +156,10 @@ os_startRoutineWrapper (
uintptr_t resultValue;
#if !defined(__VXWORKS__) && !defined(__APPLE__) && !defined(__sun)
/* FIXME: Switch to use pthread_setname_np in the future.
* Linux: pthread_setname_np(pthread_t, const char *)
* macOS: pthread_setname_np(const char *)
* FreeBSD: pthread_set_name_np(pthread_t, const char *) */
prctl(PR_SET_NAME, context->threadName);
#endif
@ -236,9 +240,7 @@ os_threadCreate (
(void)pthread_attr_setname(&attr, name);
#endif
if (pthread_getschedparam(pthread_self(), &policy, &sched_param) != 0 ||
#if !defined (OS_RTEMS_DEFS_H) && !defined (PIKEOS_POSIX)
pthread_attr_setscope (&attr, PTHREAD_SCOPE_SYSTEM) != 0 ||
#endif
pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_JOINABLE) != 0 ||
pthread_attr_setinheritsched (&attr, PTHREAD_EXPLICIT_SCHED) != 0)
{
@ -251,11 +253,6 @@ os_threadCreate (
if ( tattr.stackSize < PTHREAD_STACK_MIN ) {
tattr.stackSize = PTHREAD_STACK_MIN;
}
#endif
#ifdef OSPL_STACK_MAX
if ( tattr.stackSize > OSPL_STACK_MAX ) {
tattr.stackSize = OSPL_STACK_MAX;
}
#endif
if (pthread_attr_setstacksize (&attr, tattr.stackSize) != 0) {
rv = os_resultFail;

View file

@ -15,9 +15,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#ifndef PIKEOS_POSIX
#include <strings.h>
#endif
#include <string.h>
#include <ctype.h>
@ -50,18 +48,6 @@ os_putenv(
return result;
}
const char *
os_fileSep(void)
{
return "/";
}
const char *
os_pathSep(void)
{
return ":";
}
int
os_vsnprintf(
char *str,

0
src/os/src/snippets/code/os_stdlib_getopt.c Executable file → Normal file
View file

View file

@ -25,24 +25,10 @@
void os_stdlibInitialize(void);
#endif
#ifdef OSPL_VERSION
#ifdef PIKEOS_POSIX
#include <lwip/netdb.h>
#else
#include <netdb.h>
#endif
#endif
#if defined (__cplusplus)
extern "C" {
#endif
#define OS_OS_FILESEPCHAR '/'
#define OS_OS_PATHSEPCHAR ':'
#define OS_OS_EXESUFFIX ""
#define OS_OS_BATSUFFIX ""
#define OS_OS_LIB_LOAD_PATH_VAR "LD_LIBRARY_PATH"
#define OS_ROK R_OK
#define OS_WOK W_OK
#define OS_XOK X_OK
@ -52,10 +38,6 @@ extern "C" {
#define OS_ISREG S_ISREG
#define OS_ISLNK S_ISLNK
#define OS_PATH_MAX _POSIX_PATH_MAX
typedef DIR *os_os_dirHandle;
#if defined (__cplusplus)
}
#endif

View file

@ -61,13 +61,6 @@ uint32_t get_threadExit_thread (void *args)
return id;
}
uint32_t threadIdentity_thread (_In_ void *args)
{
char *identity = args;
os_threadFigureIdentity (identity, 512);
return 0;
}
uint32_t threadMemory_thread (_In_opt_ void *args)
{
OS_UNUSED_ARG(args);
@ -612,112 +605,6 @@ CU_Test(os_thread, join)
printf ("Ending tc_threadWaitExit\n");
}
CU_Test(os_thread, figure_identity)
{
#if !defined(_WIN32)
os_threadId thread_os_threadId;
os_threadAttr thread_os_threadAttr;
char threadId[512];
char thread_name[512];
os_result osResult;
#endif /* WIN32 */
/* Figure out the identity of the thread, where it's name is known */
printf ("Starting os_thread_figure_identity_001\n");
#ifdef WIN32
/* Untested because the identifier does not contain the name on Windows */
#else
os_threadAttrInit (&thread_os_threadAttr);
osResult = os_threadCreate (&thread_os_threadId, "threadFigureIdentity", &thread_os_threadAttr, &threadIdentity_thread, threadId);
CU_ASSERT (osResult == os_resultSuccess);
if (osResult == os_resultSuccess) {
#ifdef _WRS_KERNEL
sleepSeconds(1);
#endif
osResult = os_threadWaitExit (thread_os_threadId, NULL);
CU_ASSERT (osResult == os_resultSuccess);
if (osResult == os_resultSuccess) {
uintmax_t threadNumeric = 0;
#ifdef _WRS_KERNEL
int dum;
(void)sscanf (threadId, "%s (%d %d)", thread_name, &threadNumeric, &dum);
#else
(void)sscanf (threadId, "%s 0x%"SCNxMAX, thread_name, &threadNumeric);
#endif
CU_ASSERT (strcmp (thread_name, "threadFigureIdentity") == 0 && threadNumeric == os_threadIdToInteger(thread_os_threadId));
} else {
printf ("os_threadWaitExit failed.\n");
}
} else {
printf ("os_threadCreate failed.\n");
}
#endif /* WIN32 */
/* Figure out the identity of the thread, where it's name is unknown */
printf ("Starting os_thread_figure_identity_002\n");
#if (defined _WRS_KERNEL || defined WIN32)
{
char threadId[512];
int threadNumeric;
os_threadFigureIdentity (threadId, sizeof(threadId));
#if defined WIN32
(void)sscanf (threadId, "%"PRIx32, &threadNumeric);
#else /* VXWORKS */
(void)sscanf (index(threadId,'(') + 1, "%"PRIx32, &threadNumeric);
#endif
CU_ASSERT (threadNumeric == os_threadIdToInteger(os_threadIdSelf()));
}
#else
{
char threadId[512];
uintptr_t threadNumeric;
os_threadFigureIdentity (threadId, sizeof(threadId));
#ifdef WIN32
(void)sscanf (threadId, "%"PRIxPTR, &threadNumeric);
#else
(void)sscanf (threadId, "%"PRIxPTR, &threadNumeric);
#endif
#ifndef INTEGRITY
CU_ASSERT (threadNumeric == (uintptr_t)os_threadIdToInteger(os_threadIdSelf()));
#endif
}
#endif
/* Figure out the identity of the thread, check the return parameter */
printf ("Starting os_thread_figure_identity_003\n");
#ifdef _WRS_KERNEL
{
char threadId[512];
char threadIdString[512];
int threadNumeric;
int threadIdLen;
snprintf (threadIdString, sizeof(threadIdString), "%s (%d %d)", taskName(taskIdSelf()),os_threadIdSelf(),taskIdSelf());
threadIdLen = os_threadFigureIdentity (threadId, sizeof(threadId));
CU_ASSERT (threadIdLen == strlen(threadIdString));
}
#else
{
char threadId[512];
char threadIdString[512];
int32_t threadIdLen;
(void)snprintf (threadIdString, sizeof(threadIdString), "0x%"PRIxMAX, os_threadIdToInteger(os_threadIdSelf()));
threadIdLen = os_threadFigureIdentity (threadId, sizeof(threadId));
CU_ASSERT (threadIdLen == (int32_t)strlen(threadIdString));
}
#endif
printf ("Ending os_thread_figure_identity\n");
}
CU_Test(os_thread, attr_init)
{
os_threadAttr thread_os_threadAttr;