Tree @upstream/2.80+ds (Download .tar.gz)
- base
- build-scripts
- cudareflect
- doc
- examples
- GL
- gl-matrix-2.4.0-pruned
- GUI
- LspCpp
- patches
- prc
- tests
- webgl
- _config.yml
- abs3doutfile.h
- absyn.cc
- absyn.h
- access.cc
- access.h
- align.h
- angle.h
- application.cc
- application.h
- array.cc
- array.h
- arrayop.h
- aspy.py
- asy-keywords.el
- asy-list.pl
- asy.ico
- asy.rc
- asymptote.nsi
- asymptote.spec
- autogen.sh
- ax_pthread.m4
- bbox.h
- bbox3.h
- beziercurve.cc
- beziercurve.h
- bezierpatch.cc
- bezierpatch.h
- BUGS
- builtin.cc
- builtin.h
- callable.cc
- callable.h
- camp.l
- camp.tab.cc
- camp.tab.h
- camp.y
- camperror.cc
- camperror.h
- castop.h
- cc-mode2.el
- ChangeLog
- coder.cc
- coder.h
- coenv.cc
- coenv.h
- common.h
- config.guess
- config.h.in
- config.sub
- configure
- configure.ac
- constructor.cc
- dec.cc
- dec.h
- Delaunay.cc
- Delaunay.h
- drawclipbegin.h
- drawclipend.h
- drawelement.h
- drawfill.cc
- drawfill.h
- drawgrestore.h
- drawgroup.h
- drawgsave.h
- drawimage.h
- drawlabel.cc
- drawlabel.h
- drawlayer.h
- drawpath.cc
- drawpath.h
- drawpath3.cc
- drawpath3.h
- drawsurface.cc
- drawsurface.h
- drawverbatim.h
- entry.cc
- entry.h
- env.cc
- env.h
- envcompleter.cc
- envcompleter.h
- EnvVarUpdate.nsh
- errormsg.cc
- errormsg.h
- errors
- errortest.asy
- exp.cc
- exp.h
- EXRFiles.cc
- EXRFiles.h
- fftw++.cc
- fftw++.h
- fftw++asy.cc
- fileio.cc
- fileio.h
- findsym.pl
- flatguide.cc
- flatguide.h
- fpu.h
- frame.h
- fundec.cc
- fundec.h
- gc-8.2.0.tar.gz
- generate_enums.py
- genv.cc
- genv.h
- getopt.c
- getopt.h
- getopt1.c
- glew.c
- glrender.cc
- glrender.h
- GLTextures.cc
- GLTextures.h
- gsl.cc
- guide.cc
- guide.h
- guideflags.h
- impdatum.cc
- index.html
- inst.h
- INSTALL
- install-sh
- interact.cc
- interact.h
- item.h
- jsfile.cc
- jsfile.h
- keywords.cc
- keywords.pl
- knot.cc
- knot.h
- lex.yy.cc
- lexical.h
- libatomic_ops-7.6.12.tar.gz
- LICENSE
- LICENSE.LESSER
- lnkX64IconFix.nsh
- locate.cc
- locate.h
- lspserv.cc
- lspserv.h
- main.cc
- Makefile.in
- makeUnique.h
- material.h
- mathop.h
- memory.h
- mod.h
- modifier.h
- name.cc
- name.h
- newexp.cc
- newexp.h
- opcodes.h
- opsymbols.pl
- pair.h
- parser.cc
- parser.h
- path.cc
- path.h
- path3.cc
- path3.h
- pen.cc
- pen.h
- picture.cc
- picture.h
- pipestream.cc
- pipestream.h
- Pipfile
- policy.h
- prcfile.h
- predicates.cc
- predicates.h
- primitives.h
- process.cc
- process.h
- profile.py
- profiler.h
- program.cc
- program.h
- psfile.cc
- psfile.h
- README
- record.cc
- record.h
- refaccess.cc
- refaccess.h
- ReleaseNotes
- revision.cc
- rounding.h
- runarray.cc
- runarray.h
- runarray.in
- runbacktrace.cc
- runbacktrace.h
- runbacktrace.in
- runfile.cc
- runfile.h
- runfile.in
- runhistory.cc
- runhistory.h
- runhistory.in
- runlabel.cc
- runlabel.h
- runlabel.in
- runmath.cc
- runmath.h
- runmath.in
- runpair.cc
- runpair.h
- runpair.in
- runpath.cc
- runpath.h
- runpath.in
- runpath3d.cc
- runpath3d.h
- runpath3d.in
- runpicture.cc
- runpicture.h
- runpicture.in
- runstring.cc
- runstring.h
- runstring.in
- runsystem.cc
- runsystem.h
- runsystem.in
- runtime.cc
- runtime.h
- runtime.in
- runtime.pl
- runtimebase.in
- runtriple.cc
- runtriple.h
- runtriple.in
- seconds.h
- settings.cc
- settings.h
- shaders.cc
- shaders.h
- simpson.cc
- stack.cc
- stack.h
- statistics.h
- stm.cc
- stm.h
- symbol.cc
- symbol.h
- symbolmaps.cc
- symbolmaps.h
- table.h
- testv3d.asy
- texfile.cc
- texfile.h
- tinyexr.cc
- TODO
- tr.cc
- tr.h
- transform.h
- triple.h
- types.cc
- types.h
- util.cc
- util.h
- v3dfile.cc
- v3dfile.h
- v3dheadertypes.csv
- v3dheadertypes.h
- v3dheadertypes.py
- v3dtypes.csv
- v3dtypes.h
- v3dtypes.py
- varinit.cc
- varinit.h
- virtualfieldaccess.cc
- virtualfieldaccess.h
- vm.h
- wce
- xstream.h
align.h @upstream/2.80+ds — raw · history · blame
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | #ifndef __align_h__ #define __align_h__ 1 #ifndef HAVE_POSIX_MEMALIGN #ifdef __GLIBC_PREREQ #if __GLIBC_PREREQ(2,3) #define HAVE_POSIX_MEMALIGN #endif #else #ifdef _POSIX_SOURCE #define HAVE_POSIX_MEMALIGN #endif #endif #endif #ifdef __Array_h__ namespace Array { static const array1<Complex> NULL1; static const array2<Complex> NULL2; static const array3<Complex> NULL3; } #else #ifdef HAVE_POSIX_MEMALIGN #ifdef _AIX extern "C" int posix_memalign(void **memptr, size_t alignment, size_t size); #endif #else namespace Array { // Adapted from FFTW aligned malloc/free. Assumes that malloc is at least // sizeof(void*)-aligned. Allocated memory must be freed with free0. inline int posix_memalign0(void **memptr, size_t alignment, size_t size) { if(alignment % sizeof (void *) != 0 || (alignment & (alignment - 1)) != 0) return EINVAL; void *p0=malloc(size+alignment); if(!p0) return ENOMEM; void *p=(void *)(((size_t) p0+alignment)&~(alignment-1)); *((void **) p-1)=p0; *memptr=p; return 0; } inline void free0(void *p) { if(p) free(*((void **) p-1)); } } #endif namespace Array { template<class T> inline void newAlign(T *&v, size_t len, size_t align) { void *mem=NULL; const char *invalid="Invalid alignment requested"; const char *nomem="Memory limits exceeded"; #ifdef HAVE_POSIX_MEMALIGN int rc=posix_memalign(&mem,align,len*sizeof(T)); #else int rc=posix_memalign0(&mem,align,len*sizeof(T)); #endif if(rc == EINVAL) std::cerr << invalid << std::endl; if(rc == ENOMEM) std::cerr << nomem << std::endl; v=(T *) mem; for(size_t i=0; i < len; i++) new(v+i) T; } template<class T> inline void deleteAlign(T *v, size_t len) { for(size_t i=len; i-- > 0;) v[i].~T(); #ifdef HAVE_POSIX_MEMALIGN free(v); #else free0(v); #endif } } #endif namespace utils { inline unsigned int ceilquotient(unsigned int a, unsigned int b) { return (a+b-1)/b; } inline Complex *ComplexAlign(size_t size) { Complex *v; Array::newAlign(v,size,sizeof(Complex)); return v; } inline double *doubleAlign(size_t size) { double *v; Array::newAlign(v,size,sizeof(Complex)); return v; } template<class T> inline void deleteAlign(T *p) { #ifdef HAVE_POSIX_MEMALIGN free(p); #else Array::free0(p); #endif } } #endif |