Safe operating-system calls

The following table lists operating-system calls that are considered safe within a well-behaved C UDR on all supported platforms. Be sure to use threadsafe (_r) versions where applicable.

Category System calls Notes®
Character classification isalnum(), isalpha(), isascii(), isastream(), isatty(), iscntrl(), isdigit(), isgraph(), islower(), isspace(), isprint(), ispunct(), isupper(), isxdigit() None
String manipulation tolower(), toupper(), toascii() None
String parsing getopt(), getsubopt() None
Multibyte strings mbtowc(), wctomb(), mblen(), mbstowcs(), wcstombs() None.
String processing strcasecmp(), strcat(), strchr(), strcmp(), strcoll(), strcpy(), strcspn(), strdup(), strerror(), strlen(), strncasecmp(), strncat(), strncmp(), strncpy(), strpbrk(), strrchr(), strsignal(), strspn(), strstr(), strtod(), strtok(), strtok_r(), strtol(), strtoll(), strtoul(), strtoull(), strxfrm() None.
String formatting sprintf(), sscanf() None
Numeric processing a641(), l64a(), abs(), labs(), llabs(), atof(), atoi(), atol(), atoll(), div(), ldiv(), lldiv(), lltostr(), strtoll() None
Random-number generation srand(), rand(), srandom(), random(), srand48(), drand48(), erand48(), lrand48(), nrand48(), mrand48() The random-number generator must be reseeded whenever a thread switch might have occurred.
Numeric conversion econvert(), fconvert(), gconvert(), seconverty(), sfconvert(), sgconvert(), qeconvert(), qfconvert(), ecvt(), fcvt(), gcvt() ifx_dececvt(), ifx_decfcvt()
Time functions ascftime(), strftime(), cftime(), ctime(), ctime_r(), asctime(), asctime_r(), gmtime(), gmtime_r(), difftime(), localtime(), localtime_r()clock(), gettimeofday(), mktime() No time-zone changes are permitted.
Date functions getdate() None
Sorting and searching bsearch(), qsort(), lfind(), lsearch() None
Encryption crypt(), setkey(), encrypt() None
Memory management memccpy(), memchr(), memcmp(), memcpy(), memmove(), memset() Use memmove() and memset() only for memory that was allocated with mi_alloc().
Environment information getenv() None
Bit manipulation ffs() None
Byte manipulation swab() None
Structure-member manipulation offsetof() None
Trigonometric functions acos(), acosh(), asin(), asinh(), atan(), atan2(), atanh()cos(), cosh(), sin(), sinh(), tan(), tanh() None
Bessel functions j0(), j1(), jn(), y0(), y1(), yn() None
Root extraction cbrt(), sqrt() None
Rounding ceil(), floor(), rint() None
IEEE functions copysign(), isnan(), fabs(), fmod(), nextafter(), remainder() None
Error functions erf(), erfc() None
Exponentials and logarithms exp(), expm1(), log(), log10(), log1p(), pow() None
Gamma functions lgamma(), lgamma_r() The contents of signgam are unreliable after a thread switch.
Euclidean distance hypot() None
Tip: The system calls in the preceding table follow the Portable Operating System Interface for Computing Environments (POSIX) specification.

For a list of categories of operating-system calls that are generally unsafe in a UDR, see Unsafe operating-system calls.

The following actions are valid only in C UDRs that run on Windows™ and only if they do not interfere with the shared-memory model that the database server uses:
  • C UDRs can create additional threads or processes.
  • C UDRs can use shared memory for interprocess communication.
Important: Use of user-defined VPs can result in slightly lower performance because the thread must migrate from the CPU VP to the user-defined VP on which the C UDR executes. Use a user-defined VP only when necessary.