RAPI
R_ext/RS.h
Go to the documentation of this file.
00001 /*
00002  *  R : A Computer Language for Statistical Data Analysis
00003  *  Copyright (C) 1999-2016 The R Core Team.
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU Lesser General Public License as published by
00007  *  the Free Software Foundation; either version 2.1 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU Lesser General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU Lesser General Public License
00016  *  along with this program; if not, a copy is available at
00017  *  https://www.R-project.org/Licenses/
00018  */
00019 
00020 /* Included by R.h: API */
00021 
00022 #ifndef R_RS_H
00023 #define R_RS_H
00024 
00025 #ifndef NO_C_HEADERS
00026 # if defined(__cplusplus) && !defined(DO_NOT_USE_CXX_HEADERS)
00027 #  include <cstring>
00028 #  include <cstddef>
00029 using std::size_t;
00030 # else
00031 #  include <string.h>       /* for memcpy, memset */
00032 #  include <stddef.h> /* for size_t */
00033 # endif
00034 #endif
00035 
00036 #include <Rconfig.h>        /* for F77_APPEND_UNDERSCORE */
00037 
00038 #ifdef  __cplusplus
00039 extern "C" {
00040 #endif
00041 
00042 /* S Like Error Handling */
00043 
00044 #include <R_ext/Error.h>    /* for error and warning */
00045 
00046 #ifndef STRICT_R_HEADERS
00047 
00048 #define R_PROBLEM_BUFSIZE   4096
00049 /* Parentheses added for FC4 with gcc4 and -D_FORTIFY_SOURCE=2 */
00050 #define PROBLEM         {char R_problem_buf[R_PROBLEM_BUFSIZE];(sprintf)(R_problem_buf,
00051 #define MESSAGE                 {char R_problem_buf[R_PROBLEM_BUFSIZE];(sprintf)(R_problem_buf,
00052 #define ERROR           ),error(R_problem_buf);}
00053 #define RECOVER(x)      ),error(R_problem_buf);}
00054 #define WARNING(x)      ),warning(R_problem_buf);}
00055 #define LOCAL_EVALUATOR     
00056 #define NULL_ENTRY      
00057 #define WARN            WARNING(NULL)
00058 
00059 #endif
00060 
00061 /* S Like Memory Management */
00062 
00063 extern void *R_chk_calloc(size_t nelem, size_t elsize);
00064 extern void *R_chk_realloc(void * ptr, size_t size);
00065 extern void R_chk_free(void * ptr);
00066 
00067 #ifndef STRICT_R_HEADERS
00068 /* S-PLUS 3.x but not 5.x NULLs the pointer in the following */
00069 #define Calloc(n, t)   (t *) R_chk_calloc( (size_t) (n), sizeof(t) )
00070 #define Realloc(p,n,t) (t *) R_chk_realloc( (void *)(p), (size_t)((n) * sizeof(t)) )
00071 #define Free(p)        (R_chk_free( (void *)(p) ), (p) = NULL)
00072 #endif
00073 #define R_Calloc(n, t)   (t *) R_chk_calloc( (size_t) (n), sizeof(t) )
00074 #define R_Realloc(p,n,t) (t *) R_chk_realloc( (void *)(p), (size_t)((n) * sizeof(t)) )
00075 #define R_Free(p)      (R_chk_free( (void *)(p) ), (p) = NULL)
00076 
00077 #define Memcpy(p,q,n)  memcpy( p, q, (size_t)(n) * sizeof(*p) )
00078 
00079 /* added for 3.0.0 */
00080 #define Memzero(p,n)  memset(p, 0, (size_t)(n) * sizeof(*p))
00081 
00082 #define CallocCharBuf(n) (char *) R_chk_calloc((size_t) ((n)+1), sizeof(char))
00083 
00084 /* S Like Fortran Interface */
00085 /* These may not be adequate everywhere. Convex had _ prepending common
00086    blocks, and some compilers may need to specify Fortran linkage */
00087 
00088 #ifdef HAVE_F77_UNDERSCORE
00089 # define F77_CALL(x)    x ## _
00090 #else
00091 # define F77_CALL(x)    x
00092 #endif
00093 #define F77_NAME(x)    F77_CALL(x)
00094 #define F77_SUB(x)     F77_CALL(x)
00095 #define F77_COM(x)     F77_CALL(x)
00096 #define F77_COMDECL(x) F77_CALL(x)
00097 
00098 #ifndef NO_CALL_R
00099 void    call_R(char*, long, void**, char**, long*, char**, long, char**);
00100 #endif
00101 
00102 #ifdef  __cplusplus
00103 }
00104 #endif
00105 
00106 #endif /* R_RS_H */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines