diff --git a/src/core/ddsc/src/dds_init.c b/src/core/ddsc/src/dds_init.c index 6f66e2c..9eae64f 100644 --- a/src/core/ddsc/src/dds_init.c +++ b/src/core/ddsc/src/dds_init.c @@ -149,17 +149,10 @@ dds_init(dds_domainid_t domain) /* Set additional default participant properties */ - gv.default_plist_pp.process_id = (unsigned)os_procIdSelf(); + gv.default_plist_pp.process_id = (unsigned)os_getpid(); gv.default_plist_pp.present |= PP_PRISMTECH_PROCESS_ID; - if (os_procName(progname, sizeof(progname)) > 0) - { - gv.default_plist_pp.exec_name = dds_string_dup(progname); - } - else - { - gv.default_plist_pp.exec_name = dds_string_alloc(32); - (void) snprintf(gv.default_plist_pp.exec_name, 32, "%s: %u", DDSC_PROJECT_NAME, gv.default_plist_pp.process_id); - } + gv.default_plist_pp.exec_name = dds_string_alloc(32); + (void) snprintf(gv.default_plist_pp.exec_name, 32, "%s: %u", DDSC_PROJECT_NAME, gv.default_plist_pp.process_id); len = (uint32_t) (13 + strlen(gv.default_plist_pp.exec_name)); gv.default_plist_pp.present |= PP_PRISMTECH_EXEC_NAME; if (os_gethostname(hostname, sizeof(hostname)) == os_resultSuccess) diff --git a/src/core/ddsc/tests/dispose.c b/src/core/ddsc/tests/dispose.c index e57c1a0..6701abd 100644 --- a/src/core/ddsc/tests/dispose.c +++ b/src/core/ddsc/tests/dispose.c @@ -41,7 +41,7 @@ static char* create_topic_name(const char *prefix, char *name, size_t size) { /* Get semi random g_topic name. */ - os_procId pid = os_procIdSelf(); + os_procId pid = os_getpid(); uintmax_t tid = os_threadIdToInteger(os_threadIdSelf()); (void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid); return name; diff --git a/src/core/ddsc/tests/entity_hierarchy.c b/src/core/ddsc/tests/entity_hierarchy.c index e3ab0cf..822228a 100644 --- a/src/core/ddsc/tests/entity_hierarchy.c +++ b/src/core/ddsc/tests/entity_hierarchy.c @@ -47,7 +47,7 @@ static char* create_topic_name(const char *prefix, char *name, size_t size) { /* Get semi random g_topic name. */ - os_procId pid = os_procIdSelf(); + os_procId pid = os_getpid(); uintmax_t tid = os_threadIdToInteger(os_threadIdSelf()); (void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid); return name; diff --git a/src/core/ddsc/tests/entity_status.c b/src/core/ddsc/tests/entity_status.c index ac41795..c157f75 100644 --- a/src/core/ddsc/tests/entity_status.c +++ b/src/core/ddsc/tests/entity_status.c @@ -51,7 +51,7 @@ static char* create_topic_name(const char *prefix, char *name, size_t size) { /* Get semi random g_topic name. */ - os_procId pid = os_procIdSelf(); + os_procId pid = os_getpid(); uintmax_t tid = os_threadIdToInteger(os_threadIdSelf()); (void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid); return name; diff --git a/src/core/ddsc/tests/listener.c b/src/core/ddsc/tests/listener.c index 85d0c5e..4eba4d1 100644 --- a/src/core/ddsc/tests/listener.c +++ b/src/core/ddsc/tests/listener.c @@ -312,7 +312,7 @@ static char* create_topic_name(const char *prefix, char *name, size_t size) { /* Get semi random g_topic name. */ - os_procId pid = os_procIdSelf(); + os_procId pid = os_getpid(); uintmax_t tid = os_threadIdToInteger(os_threadIdSelf()); (void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid); return name; diff --git a/src/core/ddsc/tests/querycondition.c b/src/core/ddsc/tests/querycondition.c index ee878eb..4c4c8cf 100644 --- a/src/core/ddsc/tests/querycondition.c +++ b/src/core/ddsc/tests/querycondition.c @@ -68,7 +68,7 @@ static char* create_topic_name(const char *prefix, char *name, size_t size) { /* Get semi random g_topic name. */ - os_procId pid = os_procIdSelf(); + os_procId pid = os_getpid(); uintmax_t tid = os_threadIdToInteger(os_threadIdSelf()); (void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid); return name; diff --git a/src/core/ddsc/tests/read_instance.c b/src/core/ddsc/tests/read_instance.c index c3828a5..c99b97f 100644 --- a/src/core/ddsc/tests/read_instance.c +++ b/src/core/ddsc/tests/read_instance.c @@ -68,7 +68,7 @@ static char* create_topic_name(const char *prefix, char *name, size_t size) { /* Get semi random g_topic name. */ - os_procId pid = os_procIdSelf(); + os_procId pid = os_getpid(); uintmax_t tid = os_threadIdToInteger(os_threadIdSelf()); (void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid); return name; diff --git a/src/core/ddsc/tests/readcondition.c b/src/core/ddsc/tests/readcondition.c index 8f78b02..b1f0688 100644 --- a/src/core/ddsc/tests/readcondition.c +++ b/src/core/ddsc/tests/readcondition.c @@ -61,7 +61,7 @@ static char* create_topic_name(const char *prefix, char *name, size_t size) { /* Get semi random g_topic name. */ - os_procId pid = os_procIdSelf(); + os_procId pid = os_getpid(); uintmax_t tid = os_threadIdToInteger(os_threadIdSelf()); (void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid); return name; diff --git a/src/core/ddsc/tests/reader.c b/src/core/ddsc/tests/reader.c index 4a5f824..11f370a 100644 --- a/src/core/ddsc/tests/reader.c +++ b/src/core/ddsc/tests/reader.c @@ -65,7 +65,7 @@ static char* create_topic_name(const char *prefix, char *name, size_t size) { /* Get semi random g_topic name. */ - os_procId pid = os_procIdSelf(); + os_procId pid = os_getpid(); uintmax_t tid = os_threadIdToInteger(os_threadIdSelf()); (void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid); return name; diff --git a/src/core/ddsc/tests/reader_iterator.c b/src/core/ddsc/tests/reader_iterator.c index f30ebed..10222d0 100644 --- a/src/core/ddsc/tests/reader_iterator.c +++ b/src/core/ddsc/tests/reader_iterator.c @@ -85,7 +85,7 @@ static char* create_topic_name(const char *prefix, char *name, size_t size) { /* Get semi random g_topic name. */ - os_procId pid = os_procIdSelf(); + os_procId pid = os_getpid(); uintmax_t tid = os_threadIdToInteger(os_threadIdSelf()); (void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid); return name; diff --git a/src/core/ddsc/tests/register.c b/src/core/ddsc/tests/register.c index cb12b8b..1f17370 100644 --- a/src/core/ddsc/tests/register.c +++ b/src/core/ddsc/tests/register.c @@ -43,7 +43,7 @@ static char* create_topic_name(const char *prefix, char *name, size_t size) { /* Get semi random g_topic name. */ - os_procId pid = os_procIdSelf(); + os_procId pid = os_getpid(); uintmax_t tid = os_threadIdToInteger(os_threadIdSelf()); (void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid); return name; diff --git a/src/core/ddsc/tests/take_instance.c b/src/core/ddsc/tests/take_instance.c index eac7c9e..cef8252 100644 --- a/src/core/ddsc/tests/take_instance.c +++ b/src/core/ddsc/tests/take_instance.c @@ -69,7 +69,7 @@ static char* create_topic_name(const char *prefix, char *name, size_t size) { /* Get semi random g_topic name. */ - os_procId pid = os_procIdSelf(); + os_procId pid = os_getpid(); uintmax_t tid = os_threadIdToInteger(os_threadIdSelf()); (void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid); return name; diff --git a/src/core/ddsc/tests/topic.c b/src/core/ddsc/tests/topic.c index 57ee13e..aff59d6 100644 --- a/src/core/ddsc/tests/topic.c +++ b/src/core/ddsc/tests/topic.c @@ -38,7 +38,7 @@ static char* create_topic_name(const char *prefix, char *name, size_t size) { /* Get semi random g_topic name. */ - os_procId pid = os_procIdSelf(); + os_procId pid = os_getpid(); uintmax_t tid = os_threadIdToInteger(os_threadIdSelf()); (void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid); return name; diff --git a/src/core/ddsc/tests/unregister.c b/src/core/ddsc/tests/unregister.c index e568031..370b4dc 100644 --- a/src/core/ddsc/tests/unregister.c +++ b/src/core/ddsc/tests/unregister.c @@ -43,7 +43,7 @@ static char* create_topic_name(const char *prefix, char *name, size_t size) { /* Get semi random g_topic name. */ - os_procId pid = os_procIdSelf(); + os_procId pid = os_getpid(); uintmax_t tid = os_threadIdToInteger(os_threadIdSelf()); (void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid); return name; diff --git a/src/core/ddsc/tests/waitset.c b/src/core/ddsc/tests/waitset.c index 8ed4264..0a64ab7 100644 --- a/src/core/ddsc/tests/waitset.c +++ b/src/core/ddsc/tests/waitset.c @@ -61,7 +61,7 @@ static char* create_topic_name(const char *prefix, char *name, size_t size) { /* Get semi random g_topic name. */ - os_procId pid = os_procIdSelf(); + os_procId pid = os_getpid(); uintmax_t tid = os_threadIdToInteger(os_threadIdSelf()); (void) snprintf(name, size, "%s_pid%"PRIprocId"_tid%"PRIuMAX"", prefix, pid, tid); return name; diff --git a/src/core/ddsi/src/ddsi_iid.c b/src/core/ddsi/src/ddsi_iid.c index d8c092d..7961ff4 100644 --- a/src/core/ddsi/src/ddsi_iid.c +++ b/src/core/ddsi/src/ddsi_iid.c @@ -67,7 +67,7 @@ void ddsi_iid_init (void) os_mutexInit (&gv.dds_iid.lock); #endif - gv.dds_iid.key[0] = (uint32_t) os_procIdSelf(); + gv.dds_iid.key[0] = (uint32_t) os_getpid(); gv.dds_iid.key[1] = (uint32_t) tnow.v; gv.dds_iid.key[2] = (uint32_t) (tnow.v >> 32); gv.dds_iid.key[3] = 0xdeadbeef; diff --git a/src/core/ddsi/src/q_init.c b/src/core/ddsi/src/q_init.c index b3600f7..8a59195 100644 --- a/src/core/ddsi/src/q_init.c +++ b/src/core/ddsi/src/q_init.c @@ -1050,7 +1050,7 @@ int rtps_init (void) /* Template PP guid -- protected by privileged_pp_lock for simplicity */ gv.next_ppguid.prefix.u[0] = locator_to_hopefully_unique_uint32 (&gv.ownloc); - gv.next_ppguid.prefix.u[1] = (unsigned) os_procIdSelf (); + gv.next_ppguid.prefix.u[1] = (unsigned) os_getpid (); gv.next_ppguid.prefix.u[2] = 1; gv.next_ppguid.entityid.u = NN_ENTITYID_PARTICIPANT; diff --git a/src/os/CMakeLists.txt b/src/os/CMakeLists.txt index bdd4874..3abceab 100644 --- a/src/os/CMakeLists.txt +++ b/src/os/CMakeLists.txt @@ -26,7 +26,8 @@ set(sources src/os_errno.c src/os_iter.c src/os_strlcpy.c - src/os_dns.c) + src/os_dns.c + src/os_process.c) string(TOLOWER ${CMAKE_SYSTEM_NAME} system_name) set(system_sources @@ -38,8 +39,7 @@ set(system_sources os_platform_sync.c os_platform_thread.c os_platform_time.c - os_platform_init.c - os_platform_process.c) + os_platform_init.c) foreach(source ${system_sources}) if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/${system_name}/${source}") diff --git a/src/os/include/os/darwin/os_platform.h b/src/os/include/os/darwin/os_platform.h index 2718356..ae6eed0 100644 --- a/src/os/include/os/darwin/os_platform.h +++ b/src/os/include/os/darwin/os_platform.h @@ -39,7 +39,6 @@ extern "C" { #include "os/posix/os_platform_sync.h" #include "os/posix/os_platform_thread.h" #include "os/posix/os_platform_stdlib.h" -#include "os/posix/os_platform_process.h" #if defined (__cplusplus) } diff --git a/src/os/include/os/linux/os_platform.h b/src/os/include/os/linux/os_platform.h index 41d61ee..4f4f082 100644 --- a/src/os/include/os/linux/os_platform.h +++ b/src/os/include/os/linux/os_platform.h @@ -39,7 +39,6 @@ extern "C" { #include "os/posix/os_platform_sync.h" #include "os/posix/os_platform_thread.h" #include "os/posix/os_platform_stdlib.h" -#include "os/posix/os_platform_process.h" #if defined (__cplusplus) } diff --git a/src/os/include/os/os_process.h b/src/os/include/os/os_process.h index 252d60e..262174f 100644 --- a/src/os/include/os/os_process.h +++ b/src/os/include/os/os_process.h @@ -32,45 +32,7 @@ extern "C" { * Possible Results: * - returns the process ID of the calling process */ -OSAPI_EXPORT os_procId os_procIdSelf(void); - -/** \brief Figure out the identity of the current process - * - * Possible Results: - * - returns the actual length of procIdentity - * - * Postcondition: - * - \b procIdentity is "" - * the process identity could not be determined - * - \b procIdentity is "" | "0x" - * only the process numeric identity could be determined - * - \b procIdentity is " ()" | " (0x)" - * the process name and numeric identity could be determined - * - * \b procIdentity will not be filled beyond the specified \b procIdentitySize - */ -OSAPI_EXPORT int -os_procNamePid( - _Out_writes_z_(procIdentitySize) char *procIdentity, - _In_ size_t procIdentitySize); - -/** \brief Figure out the name of the current process - * - * Possible Results: - * - returns the actual length of procName - * - * Postcondition: - * - \b procName is "" - * the process name could not be determined - * - \b procName is "" - * the process name could be determined - * - * \b procName will not be filled beyond the specified \b procNameSize - */ -OSAPI_EXPORT int -os_procName( - _Out_writes_z_(procNameSize) char *procName, - _In_ size_t procNameSize); +OSAPI_EXPORT os_procId os_getpid(void); #if defined (__cplusplus) } diff --git a/src/os/include/os/solaris/os_platform.h b/src/os/include/os/solaris/os_platform.h index 1c07fc6..0e80ccc 100644 --- a/src/os/include/os/solaris/os_platform.h +++ b/src/os/include/os/solaris/os_platform.h @@ -39,7 +39,6 @@ extern "C" { #include "os/posix/os_platform_sync.h" #include "os/posix/os_platform_thread.h" #include "os/posix/os_platform_stdlib.h" -#include "os/posix/os_platform_process.h" #if defined (__cplusplus) } diff --git a/src/os/include/os/windows/os_platform.h b/src/os/include/os/windows/os_platform.h index 92be30a..cc81ca3 100644 --- a/src/os/include/os/windows/os_platform.h +++ b/src/os/include/os/windows/os_platform.h @@ -43,7 +43,6 @@ extern "C" { #include "os/windows/os_platform_socket.h" #include "os/windows/os_platform_sync.h" -#include "os/windows/os_platform_process.h" #include "os/windows/os_platform_thread.h" #include "os/windows/os_platform_stdlib.h" #include "os/windows/os_platform_time.h" diff --git a/src/os/include/os/windows/os_platform_process.h b/src/os/include/os/windows/os_platform_process.h deleted file mode 100644 index 2da85de..0000000 --- a/src/os/include/os/windows/os_platform_process.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright(c) 2006 to 2018 ADLINK Technology Limited and others - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License - * v. 1.0 which is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause - */ -#ifndef OS_PLATFORM_PROCESS_H -#define OS_PLATFORM_PROCESS_H - -#if defined (__cplusplus) -extern "C" { -#endif - void os_processModuleInit(void); - void os_processModuleExit(void); -#if defined (__cplusplus) -} -#endif - -#endif diff --git a/src/os/include/os/posix/os_platform_process.h b/src/os/src/os_process.c similarity index 67% rename from src/os/include/os/posix/os_platform_process.h rename to src/os/src/os_process.c index 2da85de..67e0cd6 100644 --- a/src/os/include/os/posix/os_platform_process.h +++ b/src/os/src/os_process.c @@ -9,16 +9,15 @@ * * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause */ -#ifndef OS_PLATFORM_PROCESS_H -#define OS_PLATFORM_PROCESS_H +#include "os/os.h" -#if defined (__cplusplus) -extern "C" { +os_procId +os_getpid(void) +{ +#if defined(WIN32) + return GetCurrentProcessId(); +#else + /* Mapped to taskIdSelf() in VxWorks kernel mode. */ + return getpid(); #endif - void os_processModuleInit(void); - void os_processModuleExit(void); -#if defined (__cplusplus) } -#endif - -#endif diff --git a/src/os/src/posix/os_platform_init.c b/src/os/src/posix/os_platform_init.c index 47cb845..ac9b874 100644 --- a/src/os/src/posix/os_platform_init.c +++ b/src/os/src/posix/os_platform_init.c @@ -30,14 +30,12 @@ void os_osPlatformInit (void) { os_syncModuleInit(); os_threadModuleInit(); - os_processModuleInit(); } /** \brief OS layer deinitialization */ void os_osPlatformExit (void) { - os_processModuleExit(); os_threadModuleExit(); os_syncModuleExit(); } diff --git a/src/os/src/posix/os_platform_process.c b/src/os/src/posix/os_platform_process.c deleted file mode 100644 index 93a2ff5..0000000 --- a/src/os/src/posix/os_platform_process.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright(c) 2006 to 2018 ADLINK Technology Limited and others - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License - * v. 1.0 which is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause - */ -#include "os/os.h" -#include -#include - -#ifdef __APPLE__ -#include -#endif - -#include "../snippets/code/os_posix_process.c" - -#define _OS_PROCESS_DEFAULT_NAME_LEN_ (512) -int -os_procName( - char *procName, - size_t procNameSize) -{ -#ifdef __APPLE__ - char* exec, *processName = NULL; - int ret; - uint32_t usize = _OS_PROCESS_DEFAULT_NAME_LEN_; - processName = os_malloc(usize); - *processName = 0; - if (_NSGetExecutablePath(processName, &usize) != 0) { - /* processName is longer than allocated */ - processName = os_realloc(processName, usize + 1); - if (_NSGetExecutablePath(processName, &usize) == 0) { - /* path set successful */ - } - } - exec = strrchr(processName,'/'); - if (exec) { - /* move everything following the last slash forward */ - memmove (processName, exec+1, strlen (exec+1) + 1); - } - ret = snprintf(procName, procNameSize, "%s", processName); - os_free (processName); - return ret; -#else - return snprintf(procName, procNameSize, "bla%lu", (unsigned long)getpid()); -#endif -} -#undef _OS_PROCESS_DEFAULT_NAME_LEN_ diff --git a/src/os/src/snippets/code/os_posix_process.c b/src/os/src/snippets/code/os_posix_process.c deleted file mode 100644 index 01bc0c0..0000000 --- a/src/os/src/snippets/code/os_posix_process.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright(c) 2006 to 2018 ADLINK Technology Limited and others - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License - * v. 1.0 which is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause - */ -/** \file os/posix/code/os_process.c - * \brief Posix process management - * - * Implements process management for POSIX - */ - -#include "os/os.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static os_atomic_voidp_t os_procname = OS_ATOMIC_VOIDP_INIT(0); - -/** \brief pointer to environment variables */ -#ifdef __APPLE__ -//not available on iOS, but also not currently used -//#include -#else -extern char **environ; -#endif - -/* protected functions */ -void -os_processModuleInit(void) -{ - return; -} - -void -os_processModuleExit(void) -{ - void *pname; - do { - pname = os_atomic_ldvoidp(&os_procname); - } while (!os_atomic_casvoidp(&os_procname, pname, NULL)); - os_free(pname); -} -/* public functions */ - -/** \brief Return the process ID of the calling process - * - * Possible Results: - * - returns the process ID of the calling process - */ -os_procId -os_procIdSelf(void) -{ - return getpid(); -} - -/* _OS_PROCESS_DEFAULT_CMDLINE_LEN_ is defined as - * strlen("/proc//cmdline" + 1, max_pid = 32768 on Linux, so a reason- - * able default is 20 */ -#define _OS_PROCESS_DEFAULT_CMDLINE_LEN_ (20) -#define _OS_PROCESS_PROCFS_PATH_FMT_ "/proc/%d/cmdline" -#define _OS_PROCESS_DEFAULT_NAME_LEN_ (512) - -/** \brief Figure out the identity of the current process - * - * os_procNamePid determines the numeric, and if possible named - * identity of a process. It will first check if the environment variable - * SPLICE_PROCNAME is set (which is always the case if the process is started - * via os_procCreate). If so, that value will be returned. Otherwise it will be - * attempted to determine the commandline which started the process through the - * procfs. If that fails, the PID will be returned. - * - * \param procIdentity Pointer to a char-buffer to which the result can be - * written. If a name could be resolved, the result will - * have the format "name ". Otherwise it will just - * be "". - * \param procIdentitySize Size of the buffer pointed to by procIdentitySize - * \return same as snprintf returns - */ -int -os_procNamePid( - char *procIdentity, - size_t procIdentitySize) -{ - int size; - char process_name[_OS_PROCESS_DEFAULT_NAME_LEN_]; - - size = os_procName(process_name, _OS_PROCESS_DEFAULT_NAME_LEN_); - if (size > 0) { - size = snprintf(procIdentity, procIdentitySize, "%s <%"PRIprocId">", (char *)os_atomic_ldvoidp(&os_procname), os_procIdSelf()); - } else { - /* No processname could be determined, so default to PID */ - size = snprintf(procIdentity, procIdentitySize, "<%"PRIprocId">", os_procIdSelf()); - } - return size; -} - -#undef _OS_PROCESS_DEFAULT_CMDLINE_LEN_ -#undef _OS_PROCESS_PROCFS_PATH_FMT_ -#undef _OS_PROCESS_DEFAULT_NAME_LEN_ diff --git a/src/os/src/vxworks/os_platform_process.c b/src/os/src/vxworks/os_platform_process.c deleted file mode 100644 index fc0ccdc..0000000 --- a/src/os/src/vxworks/os_platform_process.c +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright(c) 2006 to 2018 ADLINK Technology Limited and others - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License - * v. 1.0 which is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause - */ -#ifdef _WRS_KERNEL - -#include "os/os.h" - -/** \brief Return the process ID of the calling process - * - * Possible Results: - * - returns the process ID of the calling process - */ -os_procId -os_procIdSelf(void) -{ - return getpid(); /* Mapped to taskIdSelf() in kernel mode */ -} - -#else -#include "../posix/os_platform_process.c" -#endif /* _WRS_KERNEL */ diff --git a/src/os/src/windows/os_platform_init.c b/src/os/src/windows/os_platform_init.c index bce0825..e20bd91 100644 --- a/src/os/src/windows/os_platform_init.c +++ b/src/os/src/windows/os_platform_init.c @@ -23,7 +23,6 @@ void os_osPlatformInit (void) { - os_processModuleInit(); os_threadModuleInit(); os_timeModuleInit(); os_socketModuleInit(); @@ -34,7 +33,6 @@ void os_osPlatformExit (void) os_socketModuleExit(); os_timeModuleExit(); os_threadModuleExit(); - os_processModuleExit(); } /* We need this on windows to make sure the main thread of MFC applications diff --git a/src/os/src/windows/os_platform_process.c b/src/os/src/windows/os_platform_process.c deleted file mode 100644 index dd228de..0000000 --- a/src/os/src/windows/os_platform_process.c +++ /dev/null @@ -1,144 +0,0 @@ -/* - * Copyright(c) 2006 to 2018 ADLINK Technology Limited and others - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License v. 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0, or the Eclipse Distribution License - * v. 1.0 which is available at - * http://www.eclipse.org/org/documents/edl-v10.php. - * - * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause - */ -/** \file os/win32/code/os_process.c - * \brief WIN32 process management - * - * Implements process management for WIN32 - */ -#include "os/os.h" - -#include -#include -#include - -/* #642 fix : define mapping between scheduling abstraction and windows - * Windows provides 6 scheduling classes for the process - * IDLE_PRIORITY_CLASS - * BELOW_NORMAL_PRIORITY_CLASS - * NORMAL_PRIORITY_CLASS - * ABOVE_NORMAL_PRIORITY_CLASS - * HIGH_PRIORITY_CLASS - * REALTIME_PRIORITY_CLASS */ - -/* These defaults should be modifiable through configuration */ -static const os_schedClass TIMESHARE_DEFAULT_SCHED_CLASS = NORMAL_PRIORITY_CLASS; -static const os_schedClass REALTIME_DEFAULT_SCHED_CLASS = REALTIME_PRIORITY_CLASS; - -static os_atomic_voidp_t os_procname = OS_ATOMIC_VOIDP_INIT(0); - -/* Protected functions */ -void -os_processModuleInit(void) -{ - return; -} - -void -os_processModuleExit(void) -{ - void *pname; - do { - pname = os_atomic_ldvoidp(&os_procname); - } while (!os_atomic_casvoidp(&os_procname, pname, NULL)); - os_free(pname); -} - -/** \brief Return the process ID of the calling process - * - * Possible Results: - * - returns the process ID of the calling process - */ -os_procId -os_procIdSelf(void) -{ - /* returns a pseudo HANDLE to process, no need to close it */ - return GetProcessId (GetCurrentProcess()); -} - -/** \brief Figure out the identity of the current process - * - * Possible Results: - * - returns the actual length of procIdentity - * - * Postcondition: - * - \b procIdentity is "" - * the process identity could not be determined - * - \b procIdentity is "" - * only the process numeric identity could be determined - * - \b procIdentity is "name " - * the process name and numeric identity could be determined - * - * \b procIdentity will not be filled beyond the specified \b procIdentitySize - */ -#define _OS_PROC_PROCES_NAME_LEN (512) -int -os_procNamePid( - _Out_writes_z_(procIdentitySize) char *procIdentity, - _In_ size_t procIdentitySize) -{ - int size; - char process_name[_OS_PROC_PROCES_NAME_LEN]; - - size = os_procName(process_name, sizeof(process_name)); - - if (size > 0) { - size = snprintf(procIdentity, procIdentitySize, "%s <%"PRIprocId">", process_name, os_procIdSelf()); - } else { - /* No processname could be determined, so default to PID */ - size = snprintf(procIdentity, procIdentitySize, "<%"PRIprocId">", os_procIdSelf()); - } - - return size; -} - -int -os_procName( - _Out_writes_z_(procNameSize) char *procName, - _In_ size_t procNameSize) -{ - char *process_name; - - if ((process_name = os_atomic_ldvoidp(&os_procname)) == NULL) { - char *exec, *pname; - DWORD nSize, allocated = 0; - - do { - /* While procNameSize could be used (since the caller cannot - * store more data anyway, it is not used. This way the amount that - * needs to be allocated to get the full-name can be determined. */ - allocated++; - process_name = os_realloc(process_name, allocated * _OS_PROC_PROCES_NAME_LEN); - /* First parameter NULL retrieves module-name of executable */ - nSize = GetModuleFileNameA(NULL, process_name, allocated * _OS_PROC_PROCES_NAME_LEN); - - /* process_name will only be guaranteed to be NULL-terminated if nSize < - * (allocated * _OS_PROC_PROCES_NAME_LEN), so continue until that's true */ - } while (nSize >= (allocated * _OS_PROC_PROCES_NAME_LEN)); - - exec = strrchr(process_name, '\\'); - if (exec) { - /* skip all before the last '\' */ - exec++; - memmove(process_name, exec, strlen(exec) + 1); - /* Could potentially realloc; can't be bothered */ - } - do { - pname = os_atomic_ldvoidp(&os_procname); - } while (pname == NULL && !os_atomic_casvoidp(&os_procname, NULL, process_name)); - if(pname) { - os_free(process_name); - process_name = pname; - } - } - return snprintf(procName, procNameSize, "%s", process_name); -} -#undef _OS_PROC_PROCES_NAME_LEN diff --git a/src/os/tests/mutex.c b/src/os/tests/mutex.c index ea56be4..f33a313 100644 --- a/src/os/tests/mutex.c +++ b/src/os/tests/mutex.c @@ -42,9 +42,6 @@ os_threadAttr mutex_os_threadAttr; os_threadId mutex_os_threadId[4]; os_time delay1 = { 5, 0 }; os_time pdelay = { 1, 0 }; -os_procId mutex_os_procId; -os_procId mutex_os_procId1; -os_procId mutex_os_procId2; char buffer[512]; int supported_resultBusy; int loop; diff --git a/src/os/tests/rwlock.c b/src/os/tests/rwlock.c index 01b12ad..b36d144 100644 --- a/src/os/tests/rwlock.c +++ b/src/os/tests/rwlock.c @@ -57,7 +57,6 @@ os_threadAttr rwlock_os_threadAttr; os_threadId rwlock_os_threadId[RWLOCK_THREADS]; static int i; char buffer[512]; -os_procId rwlock_os_procId; int supported_resultBusy; int loop; static shared_data sd; diff --git a/src/tools/pubsub/pubsub.c b/src/tools/pubsub/pubsub.c index 2c58454..7f52f58 100644 --- a/src/tools/pubsub/pubsub.c +++ b/src/tools/pubsub/pubsub.c @@ -2196,7 +2196,7 @@ int MAIN(int argc, char *argv[]) { want_reader = 0; save_argv0 (argv[0]); - pid = (int) os_procIdSelf(); + pid = (int) os_getpid(); qreader[0] = "k=all"; qreader[1] = "R=10000/inf/inf";