Files
mars-nwe/include/nwnss/internal/nssSourceCompat.h
OpenAI aea5938593
All checks were successful
Source release / source-package (push) Successful in 1m28s
nwnss: use generic NSS runtime naming
2026-06-19 06:59:58 +02:00

273 lines
7.7 KiB
C

#ifndef NSS_SOURCE_COMPAT_H
#define NSS_SOURCE_COMPAT_H
#include <stdio.h>
/*
* Private build-environment compatibility for imported NSS sources.
* The original Linux-kernel NSS build got these NSS libc-like aliases from
* its kernel/header environment. Keep this private to the userspace NSS runtime so public
* consumers keep the normal userspace libc headers.
*/
#include <library/xStdio.h>
/*
* Do not include <library/xStdlib.h> from this global -include header.
* xStdlib.h intentionally keeps Novell's RAND_MAX value, which conflicts
* with host libc <stdlib.h> in userspace port files. Individual imported
* sources include the original NSS header when they need its ABI; private
* libc helpers used only by compat macros are declared here instead.
*/
extern void free(void *);
extern void *zalloc(size_t size);
extern void *zrealloc(void *ptr, size_t size);
extern void *mallocPage(size_t numPages);
extern void *mallocPageWithFlags(size_t numPages, unsigned int flags);
extern void *zallocPage(size_t numPages);
extern void freePage(void *page, size_t numPages);
#include <include/wio.h>
#include <public/neb.h>
#include <public/nebpub.h>
LONG GetCurrentTime(void);
LONG GetHighResolutionTimer(void);
#ifdef wPause
#undef wPause
#define wPause(_file, _mode) LB_wPause((WFile_s *)(void *)(_file), (_mode))
#endif
#ifndef UINT32
typedef LONG UINT32;
#endif
#ifndef aprintf
#define aprintf LB_aprintf
#endif
#ifndef KERN_INFO
#define KERN_INFO ""
#endif
#ifndef KERN_WARNING
#define KERN_WARNING ""
#endif
#ifndef KERN_NOTICE
#define KERN_NOTICE ""
#endif
#ifndef KERN_ERR
#define KERN_ERR ""
#endif
#ifndef KERN_ALERT
#define KERN_ALERT ""
#endif
#ifndef printk
#define printk(...) fprintf(stderr, __VA_ARGS__)
#endif
#ifndef kfree
#define kfree free
#endif
#ifndef ZOS_zWrite
#define ZOS_zWrite(_status, _key, _flags, _offset, _len, _data, _retLen) \
do { \
BOOL _nss_mpk_owned; \
NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \
(_status) = zWrite((_key), (_flags), (_offset), (_len), (_data), (_retLen)); \
NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \
} while (0)
#endif
#include <internal/nssZosCompat.h>
/*
* Original ZOS macros release the global NSS MPK lock around calls that may
* enter the OS, event layer, module-symbol loader or file backend. The
* userspace compat header is force-included into imported sources that do not
* see the full kernel nssOSAPIs.h macro set, so keep the same lock boundary
* locally without assuming every caller currently owns the lock.
*/
#define NSS_MPK_BOUNDARY_BEGIN(_owned) \
do { \
(_owned) = MPKNSS_I_OWN_SPINLOCK(); \
if (_owned) \
{ \
MPKNSS_UNLOCK(); \
} \
} while (0)
#define NSS_MPK_BOUNDARY_END(_owned) \
do { \
if (_owned) \
{ \
MPKNSS_LOCK(); \
} \
} while (0)
#ifndef ZOS_StartThread
#define ZOS_StartThread(_thread, _name, _func, _stack, _prio, _arg) \
do { \
BOOL _nss_mpk_owned; \
NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \
(void)(_name); (void)(_func); (void)(_stack); (void)(_prio); (void)(_arg); \
(_thread) = 0; \
NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \
} while (0)
#endif
#ifndef ZOS_StartThreadWithModuleHandle
#define ZOS_StartThreadWithModuleHandle(_thread, _name, _func, _stack, _prio, _arg, _module) \
do { (void)(_module); ZOS_StartThread((_thread), (_name), (_func), (_stack), (_prio), (_arg)); } while (0)
#endif
#ifndef ZOS_RegisterConsumer
#define ZOS_RegisterConsumer(_reg) \
do { \
BOOL _nss_mpk_owned; \
NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \
(void)RegisterConsumer((_reg)); \
NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \
} while (0)
#endif
#ifndef ZOS_UnRegisterConsumer
#define ZOS_UnRegisterConsumer(_consumer, _event) \
do { \
BOOL _nss_mpk_owned; \
NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \
(void)UnRegisterConsumer((_consumer), (_event)); \
NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \
} while (0)
#endif
#ifndef ZOS_ImportPublicSymbol
#define ZOS_ImportPublicSymbol(_target, _module, _name) \
do { \
BOOL _nss_mpk_owned; \
NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \
(void)(_module); (void)(_name); (_target) = NULL; \
NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \
} while (0)
#endif
#ifndef ZOS_UnImportPublicSymbol
#define ZOS_UnImportPublicSymbol(_module, _name) \
do { \
BOOL _nss_mpk_owned; \
NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \
(void)(_module); (void)(_name); \
NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \
} while (0)
#endif
#ifndef EXPORT_SYMBOL
#define EXPORT_SYMBOL(_sym)
#endif
#ifndef THIS_MODULE
#define THIS_MODULE NULL
#endif
#ifndef nss_register_module
#define nss_register_module(_name, _sym, _module) ((void)(_name), (void)(_sym), (void)(_module))
#endif
#ifndef nss_unregister_module
#define nss_unregister_module(_name) ((void)(_name))
#endif
#ifndef ZOS_zClose
#define ZOS_zClose(_status, _key) \
do { \
BOOL _nss_mpk_owned; \
NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \
(_status) = zClose((_key)); \
NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \
} while (0)
#endif
#ifndef ZOS_zOpen
#define ZOS_zOpen(_status, _rootKey, _task, _flags, _path, _rights, _outKey) \
do { \
BOOL _nss_mpk_owned; \
NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \
(_status) = zOpen((_rootKey), (_task), (_flags), (_path), (_rights), (_outKey)); \
NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \
} while (0)
#endif
#ifndef ZOS_zDelete
#define ZOS_zDelete(_status, _rootKey, _task, _flags, _path, _rights, _cb) \
do { \
BOOL _nss_mpk_owned; \
NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \
(void)(_cb); \
(_status) = zDelete((_rootKey), (_task), (_flags), (_path), (_rights), NULL); \
NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \
} while (0)
#endif
#ifndef ZOS_zCreate
#define ZOS_zCreate(_status, _rootKey, _task, _flags, _nameSpace, _path, _fileType, _attr, _createFlags, _rights, _outKey) \
do { \
BOOL _nss_mpk_owned; \
NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \
(_status) = zCreate((_rootKey), (_task), (_flags), (_nameSpace), (_path), (_fileType), (_attr), (_createFlags), (_rights), (_outKey)); \
NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \
} while (0)
#endif
#ifndef ZOS_zDIORead
#define ZOS_zDIORead(_status, _key, _offset, _count, _flags, _cb, _buf) \
do { \
BOOL _nss_mpk_owned; \
NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \
(_status) = zDIORead((_key), (_offset), (_count), (_flags), (_cb), (_buf)); \
NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \
} while (0)
#endif
#ifndef ZOS_zDIOWrite
#define ZOS_zDIOWrite(_status, _key, _offset, _count, _flags, _cb, _buf) \
do { \
BOOL _nss_mpk_owned; \
NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \
(_status) = zDIOWrite((_key), (_offset), (_count), (_flags), (_cb), (_buf)); \
NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \
} while (0)
#endif
#ifndef ZOS_zRootKey
#define ZOS_zRootKey(_status, _flags, _outKey) \
do { \
BOOL _nss_mpk_owned; \
NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \
(_status) = zRootKey((_flags), (_outKey)); \
NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \
} while (0)
#endif
#ifndef ZOS_zSetEOF
#define ZOS_zSetEOF(_status, _key, _offset, _size, _flags) \
do { \
BOOL _nss_mpk_owned; \
NSS_MPK_BOUNDARY_BEGIN(_nss_mpk_owned); \
(_status) = zSetEOF((_key), (_offset), (_size), (_flags)); \
NSS_MPK_BOUNDARY_END(_nss_mpk_owned); \
} while (0)
#endif
#ifndef errPrintf
#define errPrintf LB_errPrintf
#endif
#ifdef NSS_USERSPACE
typedef LONG SAL_ModHandle;
#ifndef DS_CREATE_ID
#define DS_CREATE_ID 1
#endif
#ifndef DSI_ENTRY_ID
#define DSI_ENTRY_ID 1
#endif
extern int (*DDCCreateContextPtr)(SAL_ModHandle taskID, int *context);
extern int (*DDCNameToIDPtr)(int context, UINT32 flags, const void *dn);
extern int (*DDCGetEntryInfoPtr)(int context, UINT32 infoflags, size_t bufsize, void *buffer);
extern void (*DDCFreeContextPtr)(int context);
extern int (*DDCLogoutPtr)(int context);
#endif
void freePage(void *page, size_t numPages);
#endif /* NSS_SOURCE_COMPAT_H */