<commit_before>/*****************************************************************************\
*                                                                             *
*   Filename:	    qword.h						      *
*									      *
*   Description:    Define a 64-bits integer class usable in C++ arithmetics. *
*                   A structure-based makeshift if also provided for C.       *
*                                                                             *
*   Notes:	    MSVC 1.5 lacks a 64-bits integer type.		      *
*		    We needed one to use EFI include files in DOS programs.   *
*		    Constraints:					      *
*		    - QWORD type usable as base types in computations.        *
*			==> Redefine all operator xx functions.		      *
*		    - No constructor option, to avoid problems with unions.   *
*			==> Use friend functions _QWORD for initializations.  *
*									      *
*		    IMPORTANT: There is a bug in the compiler (?) which	      *
*		    causes compilation errors if QWORD members are included   *
*		    in C unions. This problem does NOT happen in the absence  *
*		    of constructors for the QWORD class.		      *
*		    This bug appears for example when including efi.h.        *
*		    To work around this bug, predefine the constant	      *
*		    NO_QWORD_CONSTRUCTORS before including qword.h.	      *
*		    Then use the friend functions _QWORD(...) to explicitely  *
*		    create QWORDs if needed. Be ware of memory leaks in this  *
*		    case.						      *
*									      *
*		    IMPORTANT: By default, this file defines member functions *
*		    for printing QWORDs with the SysLib oprintf() routine.    *
*		    Including qword.h will drag in the oprintf function.      *
*		    If this is not desired, for example to make the program   *
*		    smaller, it is possible to avoid this by predefining      *
*		    constant NO_OPRINTF before including qword.h.	      *
*		    Note that using oprintf is smaller and more efficient     *
*		    than converting QWORDs to double.			      *
*									      *
*		    TO DO:						      *
*		    - Add Conversion function to decimal string, etc.	      *
*									      *
*   History:								      *
*    2000-09-15 JFL Created this file.                                        *
*    2002-02-07 JFL Added _QWORD() macros in the C version.                   *
*    2003-01-16 JFL Added operations + += - -= * *= / /= with integer args.   *
*		    Changed arguments QWORD& to const QWORD&.		      *
*		    Added optional QWORD constructors. Do NOT define them if  *
*		    constant NO_QWORD_CONSTRUCTORS is pre-defined.	      *
*    2003-01-17 JFL Conditionally compiled-out all operatorX functions. They  *
*		    may be useless when operatorX= functions are defined.     *
*		    Added operator%=.					      *
*		    Fixed memory leak of operatorX functions.		      *
*    2003-01-20 JFL Added const specifier for all methods not changing value. *
*		    Moved inline very simple functions to make code smaller.  *
*    2009-02-25 JFL Made inline every function defined here. Most aren't used.*
*    2010-10-08 JFL Bugfix: Removed inline keyword on QWORD& operator+=.      *
*    2015-08-18 JFL Added operator<< and operator>>.                          * 
*    2016-04-12 JFL Include MultiOS.h.					      *
*    2016-04-22 JFL Renamed the MULTIOS library as SYSLIB.		      *
*									      *
\*****************************************************************************/

#ifndef _QWORD_H_	/* Prevent multiple inclusions */
#define _QWORD_H_

#ifdef HAS_SYSLIB
#include "SysLib.h"	/* SysLib Library core definitions */
#endif

/* Define x86 register types */
#ifndef DWORD_DEFINED
#define DWORD_DEFINED

typedef unsigned char   BYTE;   /*  8-bits unsigned integer */
typedef unsigned short	WORD;	/* 16-bits unsigned integer */
typedef unsigned long	DWORD;	/* 32-bits unsigned integer */

/* Define the FAR qualifier for DOS, but not for Windows */
#ifdef _H2INC
  #define _MSDOS /* The h2inc.exe tool is for generating DOS code */
#endif
#ifndef FAR
  #ifdef _MSDOS
    #define FAR far
  #endif /* _MSDOS */
  #ifdef _WIN32
    #define FAR
  #endif /* _WIN32 */
  #ifdef __unix__
    #define FAR
  #endif /* __unix__ */
#endif /* FAR */

/* Common far pointers based on these types */
typedef void FAR *	LPVOID;
typedef BYTE FAR *	LPBYTE;
typedef WORD FAR *	LPWORD;
typedef DWORD FAR *	LPDWORD;

/* Manipulate bytes, words and dwords. Can be used both as rvalue and as lvalue. */
#define DWORD0(qw) (((DWORD *)(&(qw)))[0])
#define DWORD1(qw) (((DWORD *)(&(qw)))[1])

#define WORD0(qw) (((WORD *)(&(qw)))[0])
#define WORD1(qw) (((WORD *)(&(qw)))[1])
#define WORD2(qw) (((WORD *)(&(qw)))[2])
#define WORD3(qw) (((WORD *)(&(qw)))[3])

#define BYTE0(qw) (((BYTE *)(&(qw)))[0])
#define BYTE1(qw) (((BYTE *)(&(qw)))[1])
#define BYTE2(qw) (((BYTE *)(&(qw)))[2])
#define BYTE3(qw) (((BYTE *)(&(qw)))[3])
#define BYTE4(qw) (((BYTE *)(&(qw)))[4])
#define BYTE5(qw) (((BYTE *)(&(qw)))[5])
#define BYTE6(qw) (((BYTE *)(&(qw)))[6])
#define BYTE7(qw) (((BYTE *)(&(qw)))[7])

/* Reference a BYTE, WORD, DWORD, or QWORD, at offset N in a structure */
#define BYTE_AT(p, n) (*(BYTE *)((BYTE *)(p)+(int)(n)))
#define WORD_AT(p, n) (*(WORD *)((BYTE *)(p)+(int)(n)))
#define DWORD_AT(p, n) (*(DWORD *)((BYTE *)(p)+(int)(n)))
#define QWORD_AT(p, n) (*(QWORD *)((BYTE *)(p)+(int)(n)))

#endif /* defined(DWORD_DEFINED) */

/*****************************************************************************\
*           First the full-fledged implementation for C++.                    *
\*****************************************************************************/

#ifdef __cplusplus

#ifndef NO_OPRINTF
#include "oprintf.h"
#endif /* !defined(NO_OPRINTF) */

#ifdef _MSC_VER
#pragma warning(disable:4505) /* Avoid warnings "unreferenced local function has been removed" */
#endif

#ifdef _MSDOS	/* 16-bits program */

#pragma message("Using QWORD C++ class definition.")
#define QWORD_CLASS 1

class QWORD
    {<commit_msg>Disable the warning C4710 "function 'QWORD::operator=' not expanded".<commit_after>/*****************************************************************************\
*                                                                             *
*   Filename:	    qword.h						      *
*									      *
*   Description:    Define a 64-bits integer class usable in C++ arithmetics. *
*                   A structure-based makeshift if also provided for C.       *
*                                                                             *
*   Notes:	    MSVC 1.5 lacks a 64-bits integer type.		      *
*		    We needed one to use EFI include files in DOS programs.   *
*		    Constraints:					      *
*		    - QWORD type usable as base types in computations.        *
*			==> Redefine all operator xx functions.		      *
*		    - No constructor option, to avoid problems with unions.   *
*			==> Use friend functions _QWORD for initializations.  *
*									      *
*		    IMPORTANT: There is a bug in the compiler (?) which	      *
*		    causes compilation errors if QWORD members are included   *
*		    in C unions. This problem does NOT happen in the absence  *
*		    of constructors for the QWORD class.		      *
*		    This bug appears for example when including efi.h.        *
*		    To work around this bug, predefine the constant	      *
*		    NO_QWORD_CONSTRUCTORS before including qword.h.	      *
*		    Then use the friend functions _QWORD(...) to explicitely  *
*		    create QWORDs if needed. Be ware of memory leaks in this  *
*		    case.						      *
*									      *
*		    IMPORTANT: By default, this file defines member functions *
*		    for printing QWORDs with the SysLib oprintf() routine.    *
*		    Including qword.h will drag in the oprintf function.      *
*		    If this is not desired, for example to make the program   *
*		    smaller, it is possible to avoid this by predefining      *
*		    constant NO_OPRINTF before including qword.h.	      *
*		    Note that using oprintf is smaller and more efficient     *
*		    than converting QWORDs to double.			      *
*									      *
*		    TO DO:						      *
*		    - Add Conversion function to decimal string, etc.	      *
*									      *
*   History:								      *
*    2000-09-15 JFL Created this file.                                        *
*    2002-02-07 JFL Added _QWORD() macros in the C version.                   *
*    2003-01-16 JFL Added operations + += - -= * *= / /= with integer args.   *
*		    Changed arguments QWORD& to const QWORD&.		      *
*		    Added optional QWORD constructors. Do NOT define them if  *
*		    constant NO_QWORD_CONSTRUCTORS is pre-defined.	      *
*    2003-01-17 JFL Conditionally compiled-out all operatorX functions. They  *
*		    may be useless when operatorX= functions are defined.     *
*		    Added operator%=.					      *
*		    Fixed memory leak of operatorX functions.		      *
*    2003-01-20 JFL Added const specifier for all methods not changing value. *
*		    Moved inline very simple functions to make code smaller.  *
*    2009-02-25 JFL Made inline every function defined here. Most aren't used.*
*    2010-10-08 JFL Bugfix: Removed inline keyword on QWORD& operator+=.      *
*    2015-08-18 JFL Added operator<< and operator>>.                          * 
*    2016-04-12 JFL Include MultiOS.h.					      *
*    2016-04-22 JFL Renamed the MULTIOS library as SYSLIB.		      *
*    2017-06-28 JFL Disable warning "function 'QWORD::operator=' not expanded"*
*									      *
\*****************************************************************************/

#ifndef _QWORD_H_	/* Prevent multiple inclusions */
#define _QWORD_H_

#ifdef HAS_SYSLIB
#include "SysLib.h"	/* SysLib Library core definitions */
#endif

/* Define x86 register types */
#ifndef DWORD_DEFINED
#define DWORD_DEFINED

typedef unsigned char   BYTE;   /*  8-bits unsigned integer */
typedef unsigned short	WORD;	/* 16-bits unsigned integer */
typedef unsigned long	DWORD;	/* 32-bits unsigned integer */

/* Define the FAR qualifier for DOS, but not for Windows */
#ifdef _H2INC
  #define _MSDOS /* The h2inc.exe tool is for generating DOS code */
#endif
#ifndef FAR
  #ifdef _MSDOS
    #define FAR far
  #endif /* _MSDOS */
  #ifdef _WIN32
    #define FAR
  #endif /* _WIN32 */
  #ifdef __unix__
    #define FAR
  #endif /* __unix__ */
#endif /* FAR */

/* Common far pointers based on these types */
typedef void FAR *	LPVOID;
typedef BYTE FAR *	LPBYTE;
typedef WORD FAR *	LPWORD;
typedef DWORD FAR *	LPDWORD;

/* Manipulate bytes, words and dwords. Can be used both as rvalue and as lvalue. */
#define DWORD0(qw) (((DWORD *)(&(qw)))[0])
#define DWORD1(qw) (((DWORD *)(&(qw)))[1])

#define WORD0(qw) (((WORD *)(&(qw)))[0])
#define WORD1(qw) (((WORD *)(&(qw)))[1])
#define WORD2(qw) (((WORD *)(&(qw)))[2])
#define WORD3(qw) (((WORD *)(&(qw)))[3])

#define BYTE0(qw) (((BYTE *)(&(qw)))[0])
#define BYTE1(qw) (((BYTE *)(&(qw)))[1])
#define BYTE2(qw) (((BYTE *)(&(qw)))[2])
#define BYTE3(qw) (((BYTE *)(&(qw)))[3])
#define BYTE4(qw) (((BYTE *)(&(qw)))[4])
#define BYTE5(qw) (((BYTE *)(&(qw)))[5])
#define BYTE6(qw) (((BYTE *)(&(qw)))[6])
#define BYTE7(qw) (((BYTE *)(&(qw)))[7])

/* Reference a BYTE, WORD, DWORD, or QWORD, at offset N in a structure */
#define BYTE_AT(p, n) (*(BYTE *)((BYTE *)(p)+(int)(n)))
#define WORD_AT(p, n) (*(WORD *)((BYTE *)(p)+(int)(n)))
#define DWORD_AT(p, n) (*(DWORD *)((BYTE *)(p)+(int)(n)))
#define QWORD_AT(p, n) (*(QWORD *)((BYTE *)(p)+(int)(n)))

#endif /* defined(DWORD_DEFINED) */

/*****************************************************************************\
*           First the full-fledged implementation for C++.                    *
\*****************************************************************************/

#ifdef __cplusplus

#ifndef NO_OPRINTF
#include "oprintf.h"
#endif /* !defined(NO_OPRINTF) */

#ifdef _MSC_VER
#pragma warning(disable:4505) /* Avoid warnings "unreferenced local function has been removed" */
#pragma warning(disable:4710) /* Avoid warnings "function 'QWORD::operator=' not expanded" */
#endif

#ifdef _MSDOS	/* 16-bits program */

#pragma message("Using QWORD C++ class definition.")
#define QWORD_CLASS 1

class QWORD
    {
{'fraction_non_alphanumeric': 0.1747096352036643, 'fraction_numerical': 0.023229183706854246, 'mean_word_length': 2.4335860713282784, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5063352', 'n_tokens_mistral': 4318, 'n_tokens_neox': 3814, 'n_words': 1227}