par_cpp_int.cc File Reference

#include "par_config.h"
#include "par_cpp_attributes.h"
#include "par_cpp_typeof.h"
#include "par_cpp_int.h"
#include "par_cpp_lnew.h"
#include "par_cpp_vectorOp.h"

Include dependency graph for par_cpp_int.cc:

Go to the source code of this file.

Typedefs

typedef signed char schar
 C++ integer types - avoid them if you can.
typedef unsigned SIZE_T size_t
 The POSIX integer type for objects in memory.
typedef signed SIZE_T ssize_t
 The signed sibling of size_t.
typedef unsigned char uchar
 C++ integer types - avoid them if you can.
typedef unsigned uint
 C++ integer types - avoid them if you can.
typedef unsigned PTR_T uintptr_t
 The POSIX integer type that is compatible with pointers to objects.
typedef unsigned long ulong
 C++ integer types - avoid them if you can.
typedef unsigned short ushort
 C++ integer types - avoid them if you can.

Functions

int *[7] toto (int[7]&A)
int(* toto (int(&A)[7]))[7]


Detailed Description

Definition in file par_cpp_int.cc.


Typedef Documentation

typedef signed char schar

C++ integer types - avoid them if you can.

C++ knows of ten distinct integer types that are normatively different types, even if they may sometimes coincide in width and signedness. We use `one word' abreviations for these to make the appearance of the code more readable: char, uchar, schar, short, ushort, int, uint, long, ulong and wchar_t.

This is also to avoid confusions from naming the same type differently, such as `long unsigned int' or `unsigned long'.

Warning:
char, uchar, schar are three distinct types.

wchar_t is a type of its own for C++ but a typedef for C.

If they exist, long long and unsigned long long are also defined to be different types, test for their existence with the macro HAVE_LONG_LONG.

In most circumstances you should probably not use these, but use typedefs that are defined with a particular semantic instead, e.g POSIX size_t for object sizes, uintptr_t for an integer compatible with casts to void*, uintmax_t for the type of maximal width, or par::cntrl::proc_t for parXXL processes. Exceptions from this general rule are:

  • int as a return type of POSIX functions, error codes etc
  • char and wchar_t have precribed semantics, they are characters and wide characters respectively. You may use char* for strings, but also consider looking into par::sys::str. But don't use char for other purposes, in particular arithmetic on small integer types. Use int8_t or uint8_t instead.
  • template instatiations

In particular the later might be a bit tricky if you want to generate instatiations systematically. In such a case you should instantiate for the ten types above, and not for their sematic overloads like size_t etc.: size_t and uintptr_t might correspond to the same type and thus produce an error if you instantiate with them at different locations.

Definition at line 131 of file par_cpp_int.cc.

typedef unsigned SIZE_T size_t

The POSIX integer type for objects in memory.

This is the type that the sizeof operator returns. It is an unsigned integer type that controls everything that the system could address with its capacities. This does not limit the size of objects that parXXL can handle, but merely poses a limit of what can be accessed simultaneously.

See also:
off_t for total size of an object for parXXL.

uintptr_t for an integer type that is compatible with pointers.

Definition at line 56 of file par_cpp_int.cc.

typedef signed SIZE_T ssize_t

The signed sibling of size_t.

Definition at line 59 of file par_cpp_int.cc.

typedef unsigned char uchar

C++ integer types - avoid them if you can.

Definition at line 133 of file par_cpp_int.cc.

typedef unsigned uint

C++ integer types - avoid them if you can.

Definition at line 137 of file par_cpp_int.cc.

typedef unsigned PTR_T uintptr_t

The POSIX integer type that is compatible with pointers to objects.

This is guaranteed to cast back and forth to any pointer to an object type without loss of information. It is very likely that this is the same as size_t on your system but you should not rely on that.

There is a subtle difficulty with pointers to functions. The norms (C as well as C++) explicitly don't want casts from function pointers to object pointers, in particular not to void*. This is to allow for systems to use composed objects as function pointers, e.g a usual pointer plus a segment specification. This was necessary in medivial times on 16bit architectures. Nowadays this restriction is probably mostly obsolete (but perhaps some embedded systems). In particular all computing platforms (e.g POSIX) we know of tacitely assume that both sorts of pointers have the same width.

In the current state parXXL only runs on such platforms where both widths are the same and it will not compile the file par_cpp_int.h if they are not. The reason is not very profound, we want to use uintptr_t as a generic integer type to handle par::cpp::id.

Todo:
Change par::cpp::id and par::mem::hashtab etc to use uintmax_t instead of uintptr_t.

Definition at line 87 of file par_cpp_int.cc.

typedef unsigned long ulong

C++ integer types - avoid them if you can.

Definition at line 139 of file par_cpp_int.cc.

typedef unsigned short ushort

C++ integer types - avoid them if you can.

Definition at line 135 of file par_cpp_int.cc.


Function Documentation

int* [7] toto ( int A[7]  ) 

int(* toto ( int(&)  A[7]  )  )[7]


Generated on Tue Oct 13 22:03:24 2009 for parXXL by  doxygen 1.5.8