Files
mars-nwe/include/core/xStdlib.h
OpenAI 06905af3b5
All checks were successful
Source release / source-package (push) Successful in 1m30s
core: import NSS stdlib allocation helpers into libnwcore
2026-06-12 19:04:14 +02:00

207 lines
4.6 KiB
C

/****************************************************************************
|
| (C) Copyright 1985, 1991, 1993, 1996 Novell, Inc.
| All Rights Reserved.
|
| This program is free software; you can redistribute it and/or
| modify it under the terms of version 2 of the GNU General Public
| License as published by the Free Software Foundation.
|
| This program is distributed in the hope that it will be useful,
| but WITHOUT ANY WARRANTY; without even the implied warranty of
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
| GNU General Public License for more details.
|
| You should have received a copy of the GNU General Public License
| along with this program; if not, contact Novell, Inc.
|
| To contact Novell about this file by physical or electronic mail,
| you may find current contact information at www.novell.com
|
|***************************************************************************
|
| NetWare Advance File Services (NSS) module
|
|---------------------------------------------------------------------------
|
| $Author: blarsen $
| $Date: 2006-02-09 05:04:41 +0530 (Thu, 09 Feb 2006) $
|
| $RCSfile$
| $Revision: 1325 $
|
|---------------------------------------------------------------------------
| This module is used to:
| NSS Library Routine
|
| WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING! WARNING!
|
| This header file should ONLY be used for NSS internal development.
| This includes Semantic Agents (SA) and Loadable Storage Services (LSS).
| Any other use may cause conflicts which NSS will NOT fix.
+-------------------------------------------------------------------------*/
#ifndef _XSTDLIB_H_
#define _XSTDLIB_H_
#ifndef _SIZE_T
# include <size_t.h>
#endif
#include <zOmni.h>
#ifdef __cplusplus
extern "C" {
#endif
extern int LB_atoi(
const char *__nptr );
extern long int LB_atol(
const char *__nptr );
extern SQUAD LB_atoq(
const char *__nptr );
extern char *LB_itoa(
int value,
char *str,
int radix);
extern char *LB_utoa(
int value,
char *str,
int radix);
extern void LB_free(
void *__ptr );
extern void *LB_malloc(
size_t __size );
extern void *LB_realloc(
void *__ptr,
size_t __size );
extern long int LB_strtol(
const char *__nptr,
char **__endptr,
int __base );
extern unsigned long int LB_strtoul(
const char *__nptr,
char **__endptr,
int __base );
/*------------------------------ QUAD Routines -----------------------------*/
extern SQUAD LB_strtoq(
const char *__nptr,
char **__endptr,
int __base );
extern QUAD LB_strtouq(
const char *__nptr,
char **__endptr,
int __base );
/*------------------------------ RAND Routines -----------------------------*/
#ifndef RAND_MAX
#define RAND_MAX 0x7fff
#endif
extern int LB_rand(void);
extern void LB_srand(unsigned int __seed );
extern long LB_random(void);
extern void LB_srandom(unsigned int x);
extern char *LB_setstate(char *arg_state);
extern char *LB_initstate(unsigned int seed, char *arg_state, int n);
/*------------------------------ NSS Routines -----------------------------*/
extern void *LB_zalloc(
size_t size);
extern void *zalloc(
size_t size);
extern void *LB_zallocPage(
size_t numPages);
extern void *LB_mallocPage(
size_t numPages);
#define ALLOC_SLEEP_OK 0x0001
#define ZERO_FILL 0x0002
extern void *LB_mallocPageWithFlags(
size_t numPages,
unsigned int flags);
extern void *LB_mallocWithFlags(
size_t size,
unsigned int flags);
extern void LB_freePage(
void *page,
size_t numPages);
extern void *LB_zrealloc(
void *__ptr,
size_t __size);
extern void *zrealloc(
void *__ptr,
size_t __size);
extern void *LB_mallocForNCPReply(
size_t __size);
extern void LB_freeForNCPReply(
void *__ptr );
struct LoadDefinitionStructure;
extern void LB_exitMyselfAndWait(
struct LoadDefinitionStructure *moduleHandle,
int status);
extern void LB_exitMyselfAndReturn(
struct LoadDefinitionStructure *moduleHandle,
int status);
#ifdef __linux__
extern void *LB_StackAllocate( size_t __size );
extern void LB_StackFree( void *__aStack, size_t __size );
#define STACK_ALLOC_NO_ASTACK() \
aStack = (struct Stack_s *)LB_StackAllocate( sizeof(*aStack) );
#define STACK_ALLOC() \
Stack_s *aStack; \
aStack = (struct Stack_s *)LB_StackAllocate( sizeof(*aStack) );
#define STACK_FREE() \
LB_StackFree( aStack, sizeof(*aStack) ); \
aStack = NULL;
#endif
#ifndef __linux__
#define STACK_ALLOC() \
Stack_s localStack; \
Stack_s *aStack = &localStack;
#define STACK_FREE() \
aStack = NULL;
#endif
#ifdef __cplusplus
}
#endif
#endif /* _XSTDLIB_H_ */