Commit Graph

478 Commits

Author SHA1 Message Date
c75ad2673e no longer need extern "C" { } around epicsExport macros 2025-03-19 11:17:14 -05:00
b97a35fec8 Don't use __attribute__((noreturn)) on VxWorks
VxWorks does not mark abort() or exit() as noreturn.
Thus, functions declared noreturn which end in a call
to those functions cause a compiler warning on vxWorks.
2025-03-19 11:06:26 -05:00
Michael Davidsaver
48ebe2c64e Avoid initMainThread() except on vxworks
Move isOkToBlock tracking to osdThread.
Targets except vxworks can store this flag in epicsThreadOSD.
Continue to use TLS w/ vxWorks.

Note that setting of isOkToBlock for "main" thread becomes lazy.
2025-03-19 10:53:42 -05:00
Michael Davidsaver
13d6ca598c initHookRegister() make idempotent and MustSucceed 2025-03-05 10:02:38 -06:00
43e75e3901 decorate functions that do not return 2025-03-05 09:51:57 -06:00
Michael Davidsaver
7384351181 clarify cantProceed() message 2025-02-18 07:30:51 -08:00
Michael Davidsaver
1d19ba4cc2 doc and log for *MustSucceed()
Replace the "never returns NULL." statement which is
manifestly not true.
2025-02-07 09:09:22 -08:00
JJL772
144f9756ea Add iocshSetError in a bunch of places 2025-02-05 10:16:16 -06:00
DW
48eed22f3b check IOCSH_STARTUP_SCRIPT before set 2025-02-05 10:03:35 -06:00
Michael Davidsaver
e4ad4becde rationalize osdMutex
Avoids split allocation.
Eliminates special case free-list.

win32: eliminate pre-XP
rtems-score: eliminate non-fast
2024-12-29 16:35:26 -08:00
Jeremy Lorelli
721e9cc3a7 Add ABORT_ON_ASSERT flag to CONFIG_SITE
This flag causes EPICS to call abort() on assertion failures rather than
suspend the executing thread. With the epicsThreadSuspendSelf() behavior,
an IOC can end up in a difficult to detect error state where one or more
threads has essentially crashed due to an assertion failure.

This also matches the C behavior of assert(3)
2024-12-29 16:34:10 -08:00
Jeremy Lorelli
333be085c0 Fix compile error in tsSLList.h 2024-12-28 12:40:27 -08:00
Chris Johns
594e5ee9db rtems: Set the name of EPICS threads so RTEMS commands report the name
Use the NP POSIX call pthread_setname_np to set the POSIX thread name.
2024-10-31 16:21:49 -05:00
Chris Johns
83cbf8a4c7 freebsd: Add support for x86 and amd64 builds
Use the OS compiler, ie cc and c++.
2024-10-31 16:16:45 -05:00
Michael Davidsaver
f6cd43b7cc asTrap serverSpecific is dbChannel
Save/restore dbAddr::pfield around callbacks to
avoid corruption if CB forgets to restore.

Need to peak at dbChannel.h during libCom build.
So generate dbCoreAPI.h early, and add extra
-I to source location when compiling dbTrapWrite.c
2024-10-31 12:30:15 -05:00
Michael Davidsaver
152d306ad8 avoid UB with self pthread_join() 2024-10-02 09:22:00 -05:00
Michael Davidsaver
012139638d posix: epicsThreadCreateOpt() avoid leak of joinable on EPERM
On a system where RT priorities have been probed.
When creating a joinable thread, but still fails
with EPERM, the first epicsThreadOSD was leaked.
2024-10-02 09:22:00 -05:00
Érico Nogueira
8045770751 libCom: don't use std::unexpected in epicsThread.
Besides being deprecated in C++11 and removed in C++17, the intended use
case for this was always wrong, since std::unexpected() is called by the
C++ runtime when a function throws an exception that was not specified
in its "dynamic exception specification", which is different from an
exception thrown by user code which wasn't caught [1,2]. Using abort()
keeps the same behavior, but with the intended semantics.

We don't use std::abort() to simplify backwards compatibility.

[1] https://github.com/epics-base/epics-base/issues/343
[2] https://en.cppreference.com/w/cpp/error/unexpected
2024-09-09 07:27:32 -07:00
Freddie Akeroyd
dd154180bf Avoid isnan/isinf redefine in c++ on VS2013 and above 2024-09-04 09:48:03 -05:00
Freddie Akeroyd
574fe116fc protect isnan/isinf define on c++ 2024-09-04 09:48:03 -05:00
Michael Davidsaver
057eb87101 readline: only keep history for interactive session 2024-08-21 09:36:39 -05:00
Michael Davidsaver
6ca716a77f iocsh: add more iocshSetError() 2024-06-11 13:52:03 -07:00
Michael Davidsaver
77490d4939 space in errPrintf() output 2024-06-11 11:14:07 -07:00
Freddie Akeroyd
5dfc6caf3c Accept should return SOCKET rather than int 2024-03-06 09:48:26 -06:00
Freddie Akeroyd
4720b61c1f Move call to setThreadName()
The call to setThreadName() is moved to avoid a race condition that
can happen with very short lived processes. If the process terminates
very quickly e.g. is a google test runner or the msi.exe command
called from a Makefile during a build, then very occasionally a
crash can occur during process termination if setThreadName() when called
from the newly created thread. This looks to be becauae the DLL it is
trying to call gets unloaded between it getting a handle to the DLL
and making the call. Moving the setThreadName() call to the creating
thread avoids this problem. The issue was only ever seen with statically
linked epics executables, I am unsure if the way a DLL based epics
program unloads might avoid this, or just make it less likely but
still possible. As mentioned above, the issue will only ever occur
to threads that are created during process termination and so would
not affect running IOCs
2024-02-21 09:59:36 -06:00
Michael Davidsaver
07cbf00187 posix: warn on epicsSocketCreate() without osiSockAttach() 2023-12-22 10:26:28 -08:00
Michael Davidsaver
403e203325 quieting clang-tidy, use unsigned
places where we shouldn't be negative anyway
2023-12-22 10:26:28 -08:00
Michael Davidsaver
a7a56912eb default/epicsMessageQueue: initialize threadNode 2023-12-22 10:26:28 -08:00
Michael Davidsaver
fe4a32e425 default/epicsMessageQueue: avoid volatile flag
Only one place where eventSent was accessed
without locking.  Move this load earlier.
2023-12-22 10:26:28 -08:00
Michael Davidsaver
823386573f ipAddrToAsciiGlobal::run() keep scratch buffer as local 2023-12-22 10:26:28 -08:00
Michael Davidsaver
ea8247586f adjustToWorstCaseAlignment() simplify
Add some STATIC_ASSERT to check assumptions.

Only in-tree use is freeListLib to ensure chunks in
a malloc()'d block are aligned.
2023-12-22 10:26:28 -08:00
Andrew Johnson
331df3d7e4 UNRELEASED => 7.0.8 2023-12-14 16:42:10 -06:00
Andrew Johnson
2e6fd505d2 Use epicsSnprintf() for old MSVC compilers 2023-12-14 11:31:36 -06:00
Andrew Johnson
5ecf7d18a8 Clean up Clang 15 sprintf() warnings in libcom and ca 2023-12-13 13:34:25 -06:00
Andrew Johnson
56dbc949ff Add declarations to flex, cleans up Clang 15 warnings. 2023-12-12 13:44:08 -06:00
Simon Rose
6a369acd0b Add newline to help text 2023-12-05 08:05:12 -08:00
Michael Davidsaver
69d05fe5b0 Add ERROR to error messages 2023-11-26 15:25:09 -08:00
Michael Davidsaver
ffc2d0f23a incorrect error check on GetStdHandle()
Likely inconsequential as GetConsoleMode() should
return 0 when given an invalid handle.
2023-11-07 15:53:41 -08:00
Michael Davidsaver
a352865df9 print ANSI escapes to stderr
unconditionally print ANSI some escapes (to colorize errors)
to the stderr stream.
2023-11-07 15:53:22 -08:00
Michael Davidsaver
63740f2edd colorize more errlog messages 2023-11-07 15:53:22 -08:00
Michael Davidsaver
b41787b6bf doc 2023-10-22 17:42:36 -07:00
Michael Davidsaver
2ca70d3aa2 iocsh: keep history file 2023-10-22 17:42:36 -07:00
JJL772
395015aac4 Com: Make STATIC_ASSERT macro typedefs unique 2023-10-22 17:42:36 -07:00
Jack Harper
49ea46ee5e iocsh: add comment to cvtArg explaining default iocsharg behaviour 2023-10-22 17:42:36 -07:00
AlexWells
6dec68554c iocsh: Add underline separator between help outputs
Also tweaks the overall format of the message a bit.
Add tests for new help output format
2023-10-22 17:42:36 -07:00
Jeremy Lorelli
60fa2d31da libCom: Fix buggy pointer dereference in postfix() 2023-09-26 09:52:13 -07:00
Michael Davidsaver
88ea1507f4 Fix compile w/ vs2012 2023-09-22 08:20:27 -07:00
Emilio Perez
8c08c57247 Allow adding error symbols after early initialization
This was acomplished by making errSymbolAdd add the error symbol directly
into the global hash table and removing errnumlist which is not needed
anymore.

Unit tests were added for checking the following cases:
- Adding a valid symbol and checking that it exists (fixed by this change)
- Getting an existing error symbol
- Getting a non existing error symbol
- Adding an invalid error symbol (fixed by this change)
- Adding an error symbol with a code that already
  exists (fixed by this change)

Therefore, issue #268 was fixed

error: statically allocate error symbol hash table

This will allow calling errSymbolAdd before errSymBld, therefore, a
function adding error symbols can now be run before iocInit or errlogInit

error: add a constant for the minimum module number

Make adding an identical error symbol not fail

A test case was also added which test that adding an error symbol
with same error code and message as one added before will not fail

Add locking to error symbol table

This protects the cases of:
- simultaneously adding and requesting of an error symbol
- simultaneously adding many error symbols

Update release notes regarding adding error symbols
2023-09-22 08:20:19 -07:00
Michael Davidsaver
45b3bce515 epicsThreadShow() zombies
Flag when the thread has returned, but the tracking
struct is still around.  eg. in need of joining.
2023-09-22 08:19:25 -07:00
Érico Nogueira
7c4a21eab4 libCom: detect support for backtrace() with __has_include.
This is necessary in order to build epics-base with musl libc, for
example, and any other C libraries which don't include this
functionality. In order to not regress builds with older compilers, we
still support the uclibc check. Furthermore, it has been checked that
uclibc-ng (the maintained version of uclibc) doesn't install the
<execinfo.h> header when the functionality is disabled [1] [2].

To avoid repetition, we don't define HAS_EXECINFO to 0 when it is not
available.

[1] https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/Makefile.in?id=cdb07d2cd52af39feb425e6d36c02b30916b9f0a#n224
[2] https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/Makefile.in?id=cdb07d2cd52af39feb425e6d36c02b30916b9f0a#n277
2023-09-21 08:18:49 -07:00