mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-31 17:30:54 -08:00
This change will be integrated but ignored (-ay) to the gg-epcore/union sources, so that they retain HopeNames. Copied from Perforce Change: 24911 ServerID: perforce.ravenbrook.com
121 lines
2.5 KiB
C
121 lines
2.5 KiB
C
/* impl.c.mpsliban: RAVENBROOK MEMORY POOL SYSTEM LIBRARY INTERFACE (ANSI)
|
|
*
|
|
* $Id$
|
|
* Copyright (c) 2001 Ravenbrook Limited.
|
|
*
|
|
* .purpose: The purpose of this code is
|
|
* 1. to connect the MPS Library Interface to the ANSI C libraries,
|
|
* where they exist, and
|
|
* 2. to provide an example of how to implement the MPS Library
|
|
* Interface.
|
|
*
|
|
* .readership: For MPS client application developers and MPS developers.
|
|
* .sources: design.mps.lib
|
|
*
|
|
*
|
|
* TRANSGRESSIONS (rule.impl.trans)
|
|
*
|
|
* .trans.file: The ANSI standard says (in section 7.9.1) that FILE is an
|
|
* object type, and hence the casts between FILE and mps_lib_FILE (an
|
|
* incomplete type) are not necessarily valid. We assume that this trick
|
|
* works, however, in all current environments.
|
|
*/
|
|
|
|
#include "mpslib.h"
|
|
|
|
#include "mpstd.h"
|
|
|
|
#ifdef MPS_OS_SU
|
|
#include "ossu.h"
|
|
#endif
|
|
#ifdef MPS_OS_XC
|
|
#include "osxc.h"
|
|
#endif
|
|
|
|
#ifdef MPS_OS_IA
|
|
struct itimerspec; /* stop complaints from time.h */
|
|
#endif
|
|
#include <time.h>
|
|
|
|
#ifdef MPS_OS_SU
|
|
extern int fputc (int c, FILE *stream);
|
|
extern int fputs (const char *s, FILE *stream);
|
|
extern clock_t clock(void);
|
|
extern long strtol(const char *, char **, int);
|
|
/* @@@@ This doesn't do quite the right thing, but will get by. */
|
|
#define strtoul(a,b,c) (unsigned long)strtol(a, b, c)
|
|
extern void *memset(void *, int, size_t);
|
|
#endif
|
|
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
|
|
int mps_lib_get_EOF(void)
|
|
{
|
|
return EOF;
|
|
}
|
|
|
|
mps_lib_FILE *mps_lib_get_stderr(void)
|
|
{
|
|
return (mps_lib_FILE *)stderr; /* see .trans.file */
|
|
}
|
|
|
|
mps_lib_FILE *mps_lib_get_stdout(void)
|
|
{
|
|
return (mps_lib_FILE *)stdout; /* see .trans.file */
|
|
}
|
|
|
|
int mps_lib_fputc(int c, mps_lib_FILE *stream)
|
|
{
|
|
return fputc(c, (FILE *)stream); /* see .trans.file */
|
|
}
|
|
|
|
int mps_lib_fputs(const char *s, mps_lib_FILE *stream)
|
|
{
|
|
return fputs(s, (FILE *)stream); /* see .trans.file */
|
|
}
|
|
|
|
|
|
void mps_lib_abort(void)
|
|
{
|
|
abort();
|
|
}
|
|
|
|
|
|
void *mps_lib_memset(void *s, int c, size_t n)
|
|
{
|
|
return memset(s, c, n);
|
|
}
|
|
|
|
void *mps_lib_memcpy(void *s1, const void *s2, size_t n)
|
|
{
|
|
return memcpy(s1, s2, n);
|
|
}
|
|
|
|
int mps_lib_memcmp(const void *s1, const void *s2, size_t n)
|
|
{
|
|
return memcmp(s1, s2, n);
|
|
}
|
|
|
|
|
|
/* @@@@ Platform specific conversion? */
|
|
/* See http://devworld.apple.com/dev/techsupport/insidemac/OSUtilities/OSUtilities-94.html#MARKER-9-32 */
|
|
mps_clock_t mps_clock(void)
|
|
{
|
|
return (unsigned long)clock();
|
|
}
|
|
|
|
|
|
unsigned long mps_lib_telemetry_control(void)
|
|
{
|
|
char *s;
|
|
char **null = NULL;
|
|
|
|
s = getenv("MPS_TELEMETRY_CONTROL");
|
|
if(s != NULL)
|
|
return strtoul(s, null, 0);
|
|
else
|
|
return 0;
|
|
}
|