Skip to content

Commit

Permalink
Merge remote-tracking branch 'connect/10.2' into 10.2
Browse files Browse the repository at this point in the history
  • Loading branch information
sanja-byelkin committed Oct 26, 2020
2 parents 2fdc503 + dc3a693 commit 784473b
Show file tree
Hide file tree
Showing 23 changed files with 1,071 additions and 490 deletions.
56 changes: 33 additions & 23 deletions storage/connect/global.h
@@ -1,7 +1,7 @@
/***********************************************************************/
/* GLOBAL.H: Declaration file used by all CONNECT implementations. */
/* (C) Copyright MariaDB Corporation Ab */
/* Author Olivier Bertrand 1993-2018 */
/* Author Olivier Bertrand 1993-2020 */
/***********************************************************************/

/***********************************************************************/
Expand Down Expand Up @@ -89,14 +89,10 @@ extern "C" {
#define PAT_LOG "log"

#if defined(UNIX) || defined(LINUX) || defined(UNIV_LINUX)
/*********************************************************************/
/* printf does not accept null pointer for %s target. */
/*********************************************************************/
// printf does not accept null pointer for %s target
#define SVP(S) ((S) ? S : "<null>")
#else
/*********************************************************************/
/* printf accepts null pointer for %s target. */
/*********************************************************************/
// printf accepts null pointer for %s target
#define SVP(S) S
#endif

Expand All @@ -112,9 +108,6 @@ extern "C" {
/***********************************************************************/
#include "os.h"

typedef uint OFFSET;
typedef char NAME[9];

typedef struct {
ushort Length;
char String[2];
Expand All @@ -127,6 +120,7 @@ typedef struct _global *PGLOBAL;
typedef struct _globplg *PGS;
typedef struct _activity *PACTIVITY;
typedef struct _parm *PPARM;
typedef char NAME[9];

/***********************************************************************/
/* Segment Sub-Allocation block structure declares. */
Expand All @@ -135,8 +129,8 @@ typedef struct _parm *PPARM;
/* restore them if needed. This scheme implies that no SubFree be used */
/***********************************************************************/
typedef struct { /* Plug Area SubAlloc header */
OFFSET To_Free; /* Offset of next free block */
uint FreeBlk; /* Size of remaining free memory */
size_t To_Free; /* Offset of next free block */
size_t FreeBlk; /* Size of remaining free memory */
} POOLHEADER, *PPOOLHEADER;

/***********************************************************************/
Expand Down Expand Up @@ -188,11 +182,12 @@ typedef struct _parm {
/***********************************************************************/
typedef struct _global { /* Global structure */
void *Sarea; /* Points to work area */
uint Sarea_Size; /* Work area size */
size_t Sarea_Size; /* Work area size */
PACTIVITY Activityp;
char Message[MAX_STR];
char Message[MAX_STR]; /* Message (result, error, trace) */
ulong More; /* Used by jsonudf */
int Createas; /* To pass multi to ext tables */
size_t Saved_Size; /* Saved work area to_free */
bool Createas; /* To pass multi to ext tables */
void *Xchk; /* indexes in create/alter */
short Alchecked; /* Checked for ALTER */
short Mrr; /* True when doing mrr */
Expand All @@ -210,19 +205,18 @@ DllExport char *PlugReadMessage(PGLOBAL, int, char *);
DllExport char *PlugGetMessage(PGLOBAL, int);
#endif // XMSG || NEWMSG
#if defined(__WIN__)
DllExport short GetLineLength(PGLOBAL); // Console line length
DllExport short GetLineLength(PGLOBAL); // Console line length
#endif // __WIN__
DllExport PGLOBAL PlugInit(LPCSTR, uint); // Plug global initialization
DllExport int PlugExit(PGLOBAL); // Plug global termination
DllExport PGLOBAL PlugInit(LPCSTR, size_t); // Plug global initialization
DllExport int PlugExit(PGLOBAL); // Plug global termination
DllExport LPSTR PlugRemoveType(LPSTR, LPCSTR);
DllExport LPCSTR PlugSetPath(LPSTR to, LPCSTR prefix, LPCSTR name, LPCSTR dir);
DllExport BOOL PlugIsAbsolutePath(LPCSTR path);
DllExport bool AllocSarea(PGLOBAL, uint);
DllExport bool AllocSarea(PGLOBAL, size_t);
DllExport void FreeSarea(PGLOBAL);
DllExport BOOL PlugSubSet(void *, uint);
DllExport BOOL PlugSubSet(void *, size_t);
DllExport void *PlugSubAlloc(PGLOBAL, void *, size_t);
DllExport char *PlugDup(PGLOBAL g, const char *str);
DllExport void *MakePtr(void *, OFFSET);
DllExport void htrc(char const *fmt, ...);
DllExport void xtrc(uint, char const* fmt, ...);
DllExport uint GetTraceValue(void);
Expand All @@ -232,8 +226,24 @@ DllExport uint GetTraceValue(void);
#endif

/***********************************************************************/
/* Non exported routine declarations. */
/* Inline routine definitions. */
/***********************************************************************/
/***********************************************************************/
/* This routine makes a pointer from an offset to a memory pointer. */
/***********************************************************************/
inline void* MakePtr(void* memp, size_t offset) {
// return ((offset == 0) ? NULL : &((char*)memp)[offset]);
return (!offset) ? NULL : (char *)memp + offset;
} /* end of MakePtr */

/***********************************************************************/
/* This routine makes an offset from a pointer new format. */
/***********************************************************************/
//void *PlugSubAlloc(PGLOBAL, void *, size_t); // Does throw
inline size_t MakeOff(void* memp, void* ptr) {
#if defined(_DEBUG)
assert(ptr > memp);
#endif // _DEBUG
return ((!ptr) ? 0 : (size_t)((char*)ptr - (size_t)memp));
} /* end of MakeOff */

/*-------------------------- End of Global.H --------------------------*/

0 comments on commit 784473b

Please sign in to comment.