├── third_party ├── jpeg │ ├── libjpeg.map │ ├── jdosabcc.obj │ ├── jdosamsc.obj │ ├── testimg.bmp │ ├── makvms.opt │ ├── jversion.h │ ├── SConscript │ ├── readme.dos │ ├── jdosaobj.txt │ ├── maktjpeg.st │ ├── jconfig.h │ ├── makcjpeg.st │ ├── makdjpeg.st │ └── jcinit.c ├── zlib │ ├── ChangeLog │ ├── zlib.3.pdf │ ├── SConscript │ ├── zlib.pc.in │ ├── zlib.pc.cmakein │ ├── inffast.h │ ├── gzclose.c │ ├── zlib.map │ ├── uncompr.c │ └── INDEX ├── pthread-w32 │ ├── MAINTAINERS │ ├── PROGRESS │ ├── TODO │ ├── README.WinCE │ ├── tests │ │ ├── Debug.txt │ │ ├── Debug.dsw │ │ ├── SIZES.GC │ │ ├── SIZES.GCE │ │ ├── SIZES.VC │ │ ├── SIZES.VCE │ │ ├── SIZES.VSE │ │ ├── README │ │ ├── Debug.plg │ │ ├── sizes.c │ │ ├── exit1.c │ │ ├── delay1.c │ │ ├── barrier1.c │ │ ├── barrier2.c │ │ ├── exit2.c │ │ ├── rwlock1.c │ │ ├── create1.c │ │ ├── spin1.c │ │ ├── exit3.c │ │ ├── equal1.c │ │ ├── self2.c │ │ ├── join0.c │ │ ├── mutex2.c │ │ ├── rwlock2.c │ │ ├── mutex2r.c │ │ ├── mutex2e.c │ │ ├── join2.c │ │ ├── README.BENCHTESTS │ │ ├── once1.c │ │ ├── mutex1.c │ │ ├── self1.c │ │ ├── mutex8.c │ │ ├── spin2.c │ │ ├── mutex3.c │ │ ├── mutex3e.c │ │ ├── mutex3r.c │ │ ├── kill1.c │ │ └── join3.c │ ├── SConscript │ ├── builddmc.bat │ ├── pthread.dsw │ ├── Nmakefile │ ├── fork.c │ ├── manual │ │ ├── pthread_equal.html │ │ └── pthread_exit.html │ ├── sync.c │ ├── pthread_getconcurrency.c │ ├── exit.c │ ├── cancel.c │ ├── tsd.c │ ├── pthread_getunique_np.c │ ├── pthread_mutexattr_setkind_np.c │ ├── pthread_mutexattr_getkind_np.c │ ├── spin.c │ ├── pthread_setconcurrency.c │ ├── ptw32_is_attr.c │ ├── barrier.c │ ├── ptw32_calloc.c │ ├── misc.c │ ├── pthread_attr_getinheritsched.c │ ├── pthread_attr_setschedpolicy.c │ ├── pthread_num_processors_np.c │ ├── nonportable.c │ ├── pthread_attr_getschedparam.c │ ├── pthread_mutexattr_gettype.c │ ├── condvar.c │ ├── ptw32_rwlock_cancelwrwait.c │ ├── pthread_attr_getscope.c │ ├── pthread_attr_setinheritsched.c │ ├── sem_close.c │ ├── pthread_attr_getschedpolicy.c │ ├── sem_unlink.c │ ├── sched.c │ ├── private.c │ ├── attr.c │ ├── sem_open.c │ ├── rwlock.c │ ├── pthread_attr_setscope.c │ ├── pthread_attr_setschedparam.c │ ├── pthread_getw32threadhandle_np.c │ ├── pthread.c │ ├── sched_getscheduler.c │ ├── pthread_barrier_init.c │ ├── pthread_spin_unlock.c │ ├── README.Watcom │ └── mutex.c ├── libpng │ ├── libpng.pc.in │ ├── SConscript │ ├── libpngpf.3 │ └── TODO ├── zopfli_build │ └── SConscript └── libimagequant_build │ └── SConscript ├── .gitignore ├── .gitmodules ├── src ├── JPEGReader.h ├── MedianCut32bitQuantizer.h ├── LPType.h ├── PNGReader.h ├── lightpng.h ├── PaletteOptimizer.h ├── MedianCut32bitQuantizer.cpp ├── JPEGReader.cpp ├── PNGWriter.h ├── Quantizer.h ├── BitChanger.h └── PaletteOptimizer.cpp ├── no_opensource ├── ATCWriter.h └── PVRWriter.h └── LICENSE.rst /third_party/jpeg/libjpeg.map: -------------------------------------------------------------------------------- 1 | LIBJPEG_8.0 { 2 | global: 3 | *; 4 | }; 5 | -------------------------------------------------------------------------------- /third_party/zlib/ChangeLog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibukawa/lightpng/HEAD/third_party/zlib/ChangeLog -------------------------------------------------------------------------------- /third_party/zlib/zlib.3.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibukawa/lightpng/HEAD/third_party/zlib/zlib.3.pdf -------------------------------------------------------------------------------- /third_party/jpeg/jdosabcc.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibukawa/lightpng/HEAD/third_party/jpeg/jdosabcc.obj -------------------------------------------------------------------------------- /third_party/jpeg/jdosamsc.obj: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibukawa/lightpng/HEAD/third_party/jpeg/jdosamsc.obj -------------------------------------------------------------------------------- /third_party/jpeg/testimg.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shibukawa/lightpng/HEAD/third_party/jpeg/testimg.bmp -------------------------------------------------------------------------------- /third_party/pthread-w32/MAINTAINERS: -------------------------------------------------------------------------------- 1 | CVS Repository maintainers 2 | 3 | Ross Johnson rpj@ise.canberra.edu.au 4 | Ben Elliston bje@cygnus.com 5 | -------------------------------------------------------------------------------- /third_party/pthread-w32/PROGRESS: -------------------------------------------------------------------------------- 1 | Please see the ANNOUNCE file "Level of Standards Conformance" 2 | or the web page: 3 | 4 | http://sources.redhat.com/pthreads-win32/conformance.html 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | 6 | # Compiled Dynamic libraries 7 | *.so 8 | 9 | # Compiled Static libraries 10 | *.lai 11 | *.la 12 | *.a 13 | 14 | # Compiled Python module 15 | *.pyc 16 | -------------------------------------------------------------------------------- /third_party/jpeg/makvms.opt: -------------------------------------------------------------------------------- 1 | ! A pointer to the VAX/VMS C Run-Time Shareable Library. 2 | ! This file is needed by makefile.mms and makefile.vms, 3 | ! but only for the older VAX C compiler. DEC C does not need it. 4 | Sys$Library:VAXCRTL.EXE /Share 5 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "third_party/zopfli"] 2 | path = third_party/zopfli 3 | url = https://code.google.com/p/zopfli/ 4 | [submodule "third_party/libimagequant"] 5 | path = third_party/libimagequant 6 | url = git://github.com/pornel/improved-pngquant.git 7 | -------------------------------------------------------------------------------- /third_party/pthread-w32/TODO: -------------------------------------------------------------------------------- 1 | Things that aren't done yet 2 | --------------------------- 3 | 4 | 1. Implement PTHREAD_PROCESS_SHARED for semaphores, mutexes, 5 | condition variables, read/write locks, barriers. 6 | 7 | 8 | -------------------------------------------------------------------------------- /third_party/pthread-w32/README.WinCE: -------------------------------------------------------------------------------- 1 | WinCE port 2 | ---------- 3 | (See the file WinCE-PORT for a detailed explanation.) 4 | 5 | Make sure you define "WINCE" amongst your compiler flags (eg. -DWINCE). 6 | The config.h file will define all the necessary defines for you. 7 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/Debug.txt: -------------------------------------------------------------------------------- 1 | This project is used to debug individual test case programs. 2 | 3 | To build and debug a test case: 4 | - add the .c file to this project; 5 | - remove any .c files from other test cases from this project. 6 | - build and debug as usual. -------------------------------------------------------------------------------- /third_party/pthread-w32/SConscript: -------------------------------------------------------------------------------- 1 | Import('env') 2 | 3 | ccflags = [ 4 | '-DPTW32_BUILD_INLINED', 5 | '-DPTW32_STATIC_LIB', 6 | '-DHAVE_PTW32_CONFIG_H', 7 | '-O3', 8 | '-m32' 9 | ] 10 | env.Library('pthread', 11 | ['pthread.c'], CCFLAGS=ccflags, CPPPATH=['.']) 12 | -------------------------------------------------------------------------------- /third_party/zlib/SConscript: -------------------------------------------------------------------------------- 1 | Import('env') 2 | 3 | ccflags = ['-O3', '-m32'] 4 | 5 | env.Library('z', 6 | ['adler32.c', 'compress.c', 'crc32.c', 'deflate.c', 'gzclose.c', 'gzlib.c', 'gzread.c', 7 | 'gzwrite.c', 'infback.c', 'inflate.c', 'inftrees.c', 'inffast.c', 'trees.c', 'uncompr.c', 'zutil.c'], 8 | CCFLAGS = ccflags) 9 | -------------------------------------------------------------------------------- /third_party/zlib/zlib.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | sharedlibdir=@sharedlibdir@ 5 | includedir=@includedir@ 6 | 7 | Name: zlib 8 | Description: zlib compression library 9 | Version: @VERSION@ 10 | 11 | Requires: 12 | Libs: -L${libdir} -L${sharedlibdir} -lz 13 | Cflags: -I${includedir} 14 | -------------------------------------------------------------------------------- /third_party/libpng/libpng.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ 5 | 6 | Name: libpng 7 | Description: Loads and saves PNG files 8 | Version: @PNGLIB_VERSION@ 9 | Libs: -L${libdir} -lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ 10 | Libs.private: @LIBS@ 11 | Cflags: -I${includedir} 12 | -------------------------------------------------------------------------------- /third_party/zlib/zlib.pc.cmakein: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=@CMAKE_INSTALL_PREFIX@ 3 | libdir=@INSTALL_LIB_DIR@ 4 | sharedlibdir=@INSTALL_LIB_DIR@ 5 | includedir=@INSTALL_INC_DIR@ 6 | 7 | Name: zlib 8 | Description: zlib compression library 9 | Version: @VERSION@ 10 | 11 | Requires: 12 | Libs: -L${libdir} -L${sharedlibdir} -lz 13 | Cflags: -I${includedir} 14 | -------------------------------------------------------------------------------- /src/JPEGReader.h: -------------------------------------------------------------------------------- 1 | #ifndef JPEGREADER_H 2 | #define JPEGREADER_H 3 | 4 | #include 5 | #include "lightpng.h" 6 | #include "Image.h" 7 | 8 | class JPEGReader : public Image 9 | { 10 | public: 11 | explicit JPEGReader(const char* filepath); 12 | ~JPEGReader(); 13 | 14 | private: 15 | jpeg_decompress_struct jpeginfo_; 16 | jpeg_error_mgr jpegerr_; 17 | 18 | void destroy(); 19 | }; 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /third_party/jpeg/jversion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * jversion.h 3 | * 4 | * Copyright (C) 1991-2012, Thomas G. Lane, Guido Vollbeding. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains software version identification. 9 | */ 10 | 11 | 12 | #define JVERSION "8d 15-Jan-2012" 13 | 14 | #define JCOPYRIGHT "Copyright (C) 2012, Thomas G. Lane, Guido Vollbeding" 15 | -------------------------------------------------------------------------------- /third_party/pthread-w32/builddmc.bat: -------------------------------------------------------------------------------- 1 | ; Build the pthreads library with the Digital Mars Compiler 2 | ; 3 | set DMCDIR=c:\dm 4 | 5 | ; RELEASE 6 | %DMCDIR%\bin\dmc -D_WIN32_WINNT -D_MT -DHAVE_PTW32_CONFIG_H -I.;c:\dm\include -o+all -WD pthread.c user32.lib+kernel32.lib+wsock32.lib -L/impl -L/NODEBUG -L/SU:WINDOWS 7 | 8 | ; DEBUG 9 | %DMCDIR%\bin\dmc -g -D_WIN32_WINNT -D_MT -DHAVE_PTW32_CONFIG_H -I.;c:\dm\include -o+all -WD pthread.c user32.lib+kernel32.lib+wsock32.lib -L/impl -L/SU:WINDOWS 10 | -------------------------------------------------------------------------------- /third_party/zlib/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /third_party/libpng/SConscript: -------------------------------------------------------------------------------- 1 | Import('env') 2 | 3 | ccflags = ['-O3', '-m32'] 4 | 5 | env.StaticLibrary( 6 | 'libpng', 7 | ['png.c', 'pngset.c', 'pngget.c', 'pngrutil.c', 'pngtrans.c', 8 | 'pngwutil.c', 'pngmem.c', 'pngpread.c', 'pngread.c', 'pngerror.c', 9 | 'pngwrite.c', 'pngrtran.c', 'pngwtran.c', 'pngrio.c', 'pngwio.c'], 10 | LIBS=['z', 'zopfli'], 11 | LIBPATH=['../zopfli_build/'], 12 | CPPPATH=['../zlib/', '../zopfli/src/zopfli'], 13 | CCFLAGS = ccflags 14 | ) 15 | -------------------------------------------------------------------------------- /third_party/jpeg/SConscript: -------------------------------------------------------------------------------- 1 | Import('env') 2 | 3 | ccflags = ['-O3', '-m32'] 4 | 5 | env.Library('jpeg', 6 | ['jaricom.c', 'jcomapi.c', 'jutils.c', 'jerror.c', 'jmemmgr.c', 7 | 'jmemansi.c', 'jdapimin.c', 'jdapistd.c', 'jdarith.c', 'jdtrans.c', 8 | 'jdatasrc.c', 'jdmaster.c', 'jdinput.c', 'jdmarker.c', 'jdhuff.c', 9 | 'jdmainct.c', 'jdcoefct.c', 'jdpostct.c', 'jddctmgr.c', 'jidctfst.c', 10 | 'jidctflt.c', 'jidctint.c', 'jdsample.c', 'jdcolor.c', 'jquant1.c', 11 | 'jquant2.c', 'jdmerge.c'], 12 | CCFLAGS = ccflags) 13 | 14 | -------------------------------------------------------------------------------- /third_party/pthread-w32/pthread.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "pthread"=.\pthread.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/Debug.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "Debug"=.\Debug.dsp - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /src/MedianCut32bitQuantizer.h: -------------------------------------------------------------------------------- 1 | #ifndef MEDIAN_CUT_32BIT_QUANTIZER_H 2 | #define MEDIAN_CUT_32BIT_QUANTIZER_H 3 | 4 | #include "Quantizer.h" 5 | #include "LPType.h" 6 | #include "Image.h" 7 | #include "PNGWriter.h" 8 | 9 | static inline unsigned char CLAMP(int value) 10 | { 11 | return (value >= 0 ? (value <= 255 ? value : 255) : 0); 12 | } 13 | 14 | class MedianCut32bitQuantizer : public Quantizer 15 | { 16 | public: 17 | MedianCut32bitQuantizer(size_t width, size_t height) : Quantizer(width, height) {} 18 | private: 19 | void process_(); 20 | }; 21 | 22 | void median_cut_32bit_quantize(Image& image, PNGWriter& writer, bool hasAlphaChannel); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /no_opensource/ATCWriter.h: -------------------------------------------------------------------------------- 1 | #ifndef ATCWRITER_H 2 | #define ATCWRITER_H 3 | 4 | #include "LPType.h" 5 | #include 6 | 7 | class ATCWriter 8 | { 9 | public: 10 | explicit ATCWriter(size_t width, size_t height) 11 | : texture_(0), width_(width), height_(height), size_(0) {} 12 | virtual ~ATCWriter(); 13 | 14 | void process(buffer_t src, bool hasAlpha); 15 | void write(const char* filepath); 16 | void writeWithHeader(const char* filepath); 17 | void writeToPNG(const char* filepath); 18 | 19 | private: 20 | TQonvertImage* texture_; 21 | size_t width_, height_, size_; 22 | 23 | void destroy(); 24 | }; 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /src/LPType.h: -------------------------------------------------------------------------------- 1 | #ifndef LPTYPE_H 2 | #define LPTYPE_H 3 | 4 | #include 5 | #include 6 | 7 | template 8 | static inline void clamp(T& value, int min_value, int max_value) 9 | { 10 | value = static_cast( 11 | std::min( 12 | std::max( 13 | static_cast(value), 14 | min_value), 15 | max_value)); 16 | } 17 | 18 | #include 19 | 20 | typedef boost::shared_array rows_t; 21 | typedef boost::shared_array buffer_t; 22 | typedef boost::shared_array palette_t; 23 | typedef boost::shared_array trans_t; 24 | 25 | #endif 26 | 27 | -------------------------------------------------------------------------------- /src/PNGReader.h: -------------------------------------------------------------------------------- 1 | #ifndef PNGREADER_H 2 | #define PNGREADER_H 3 | 4 | #include 5 | #include "LPType.h" 6 | #include "lightpng.h" 7 | #include "Image.h" 8 | 9 | class PNGReader : public Image 10 | { 11 | public: 12 | explicit PNGReader(const char* filepath); 13 | virtual ~PNGReader(); 14 | 15 | bool hasAlpha() const { return hasAlpha_; }; 16 | bool hasAlphaChannel() const { return channels_ == 4; } 17 | 18 | size_t channels() const throw() { return channels_; } 19 | 20 | private: 21 | png_structp png_; 22 | png_infop info_, end_; 23 | 24 | bool hasAlpha_; 25 | size_t channels_; 26 | 27 | void checkHasAlpha(); 28 | 29 | void destroy(); 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /third_party/jpeg/readme.dos: -------------------------------------------------------------------------------- 1 | This archive contains a DOS-friendly version of the Independent JPEG Group's 2 | source code. It differs from the normal distribution in that: 3 | 4 | 1. The archive format is zip rather than tar+gzip. You should be able to 5 | unpack it with PKUNZIP (2.04g or later) or Info-Zip's unzip or 7-Zip. 6 | 7 | 2. Newlines have been converted from Unix (LF) to DOS (CR/LF) style in all 8 | text files, but not in the binary files (test*.*). 9 | 10 | 3. Object files have been included for jmemdosa.asm. See jdosaobj.txt. 11 | 12 | Please see the main README file for the primary documentation. 13 | 14 | If you'd rather have a non-DOSified archive, see the ARCHIVE LOCATIONS section 15 | of README. 16 | -------------------------------------------------------------------------------- /third_party/zopfli_build/SConscript: -------------------------------------------------------------------------------- 1 | Import('env') 2 | 3 | ccflags = ['-O3', '-m32'] 4 | 5 | env.StaticLibrary( 6 | 'zopfli', 7 | ['../zopfli/src/zopfli/blocksplitter.c', 8 | '../zopfli/src/zopfli/cache.c', 9 | '../zopfli/src/zopfli/deflate.c', 10 | '../zopfli/src/zopfli/gzip_container.c', 11 | '../zopfli/src/zopfli/hash.c', 12 | '../zopfli/src/zopfli/katajainen.c', 13 | '../zopfli/src/zopfli/lz77.c', 14 | '../zopfli/src/zopfli/squeeze.c', 15 | '../zopfli/src/zopfli/tree.c', 16 | '../zopfli/src/zopfli/util.c', 17 | '../zopfli/src/zopfli/zlib_container.c', 18 | '../zopfli/src/zopfli/zopfli_lib.c'], 19 | LIBS=['z'], 20 | LIBPATH=[], 21 | CPPPATH=['../zopfli/'], 22 | CCFLAGS = ccflags 23 | ) 24 | -------------------------------------------------------------------------------- /third_party/zlib/gzclose.c: -------------------------------------------------------------------------------- 1 | /* gzclose.c -- zlib gzclose() function 2 | * Copyright (C) 2004, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include "gzguts.h" 7 | 8 | /* gzclose() is in a separate file so that it is linked in only if it is used. 9 | That way the other gzclose functions can be used instead to avoid linking in 10 | unneeded compression or decompression routines. */ 11 | int ZEXPORT gzclose(file) 12 | gzFile file; 13 | { 14 | #ifndef NO_GZCOMPRESS 15 | gz_statep state; 16 | 17 | if (file == NULL) 18 | return Z_STREAM_ERROR; 19 | state = (gz_statep)file; 20 | 21 | return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); 22 | #else 23 | return gzclose_r(file); 24 | #endif 25 | } 26 | -------------------------------------------------------------------------------- /no_opensource/PVRWriter.h: -------------------------------------------------------------------------------- 1 | #ifndef PVRWRITER_H 2 | #define PVRWRITER_H 3 | 4 | #include "LPType.h" 5 | 6 | namespace pvrtexture 7 | { 8 | class CPVRTexture; 9 | class CPVRTextureHeader; 10 | }; 11 | 12 | class PVRWriter 13 | { 14 | public: 15 | explicit PVRWriter(size_t width, size_t height) 16 | : pvr_(0), header_(0), width_(width), height_(height), size_(0) {} 17 | virtual ~PVRWriter(); 18 | 19 | void process(buffer_t src, bool hasAlpha); 20 | void write(const char* filepath); 21 | void writeToLegacy(const char* filepath); 22 | void writeToPNG(const char* filepath); 23 | 24 | private: 25 | pvrtexture::CPVRTexture* pvr_; 26 | pvrtexture::CPVRTextureHeader* header_; 27 | size_t width_, height_, size_; 28 | 29 | void destroy(); 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /third_party/jpeg/jdosaobj.txt: -------------------------------------------------------------------------------- 1 | This archive contains already-assembled object files for JMEMDOSA.ASM 2 | of the Independent JPEG Group's JPEG package. These files will be helpful 3 | if you want to compile the IJG code for DOS, but don't have an assembler. 4 | 5 | These files were prepared from the 3/13/1992 version of JMEMDOSA.ASM, 6 | which is still unchanged as of mid-1998. You can use these files with 7 | releases 3 through 6 of the IJG code, and probably future releases too. 8 | 9 | To use these files, copy the proper version to JMEMDOSA.OBJ. Make sure 10 | this file has a newer date than JMEMDOSA.ASM. Then compile the code as 11 | usual. 12 | 13 | Object files included: 14 | 15 | JDOSAMSC.OBJ For Microsoft C version 5 or later. 16 | JDOSABCC.OBJ For Borland C version 3.0 or later. 17 | -------------------------------------------------------------------------------- /src/lightpng.h: -------------------------------------------------------------------------------- 1 | #ifndef LIGHTPNG_H 2 | #define LIGHTPNG_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | enum Mode 9 | { 10 | helpMode, 11 | textureMode 12 | }; 13 | 14 | enum InputFileType 15 | { 16 | JPEGFile, 17 | PNGFile 18 | }; 19 | 20 | enum OutputFileType 21 | { 22 | MaskPNGFile, 23 | AlphaPNGFile, 24 | FullColorPNGFile, 25 | IndexedColorPNGFile, 26 | IndexedReducedColorPNGFile, 27 | PVRFile, 28 | LegacyPVRFile, 29 | ATCFile, 30 | ATCPlusHeaderFile, 31 | PreviewMaskPNGFile, 32 | PreviewAlphaPNGFile, 33 | PreviewIndexedReducedColorPNGFile, 34 | PreviewPVRFile, 35 | PreviewATCFile 36 | }; 37 | 38 | typedef std::pair output_type; 39 | typedef std::vector output_list; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /third_party/libpng/libpngpf.3: -------------------------------------------------------------------------------- 1 | .TH LIBPNGPF 3 "January 24, 2013" 2 | .SH NAME 3 | libpng \- Portable Network Graphics (PNG) Reference Library 1.5.14 4 | (private functions) 5 | .SH SYNOPSIS 6 | \fB#include \fI"pngpriv.h" 7 | 8 | \fBAs of libpng version \fP\fI1.5.1\fP\fB, this section is no longer \fP\fImaintained\fP\fB, now that the private function prototypes are hidden in pngpriv.h and not accessible to applications. Look in pngpriv.h for the prototypes and a short description of each \fIfunction. 9 | 10 | .SH DESCRIPTION 11 | The functions previously listed here are used privately by libpng 12 | and are not recommended for use by applications. They are 13 | not "exported" to applications using shared libraries. 14 | 15 | .SH SEE ALSO 16 | .BR "png"(5), " libpng"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5) 17 | .SH AUTHOR 18 | Glenn Randers-Pehrson 19 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/SIZES.GC: -------------------------------------------------------------------------------- 1 | Sizes of pthreads-win32 structs 2 | ------------------------------- 3 | pthread_t 8 4 | ptw32_thread_t 160 5 | pthread_attr_t_ 28 6 | sem_t_ 12 7 | pthread_mutex_t_ 28 8 | pthread_mutexattr_t_ 12 9 | pthread_spinlock_t_ 8 10 | pthread_barrier_t_ 36 11 | pthread_barrierattr_t_ 4 12 | pthread_key_t_ 16 13 | pthread_cond_t_ 32 14 | pthread_condattr_t_ 4 15 | pthread_rwlock_t_ 28 16 | pthread_rwlockattr_t_ 4 17 | pthread_once_t_ 16 18 | ptw32_cleanup_t 12 19 | ptw32_mcs_node_t_ 16 20 | sched_param 4 21 | ------------------------------- 22 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/SIZES.GCE: -------------------------------------------------------------------------------- 1 | Sizes of pthreads-win32 structs 2 | ------------------------------- 3 | pthread_t 8 4 | ptw32_thread_t 96 5 | pthread_attr_t_ 28 6 | sem_t_ 12 7 | pthread_mutex_t_ 28 8 | pthread_mutexattr_t_ 12 9 | pthread_spinlock_t_ 8 10 | pthread_barrier_t_ 36 11 | pthread_barrierattr_t_ 4 12 | pthread_key_t_ 16 13 | pthread_cond_t_ 32 14 | pthread_condattr_t_ 4 15 | pthread_rwlock_t_ 28 16 | pthread_rwlockattr_t_ 4 17 | pthread_once_t_ 16 18 | ptw32_cleanup_t 12 19 | ptw32_mcs_node_t_ 16 20 | sched_param 4 21 | ------------------------------- 22 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/SIZES.VC: -------------------------------------------------------------------------------- 1 | Sizes of pthreads-win32 structs 2 | ------------------------------- 3 | pthread_t 16 4 | ptw32_thread_t 432 5 | pthread_attr_t_ 40 6 | sem_t_ 24 7 | pthread_mutex_t_ 48 8 | pthread_mutexattr_t_ 12 9 | pthread_spinlock_t_ 16 10 | pthread_barrier_t_ 64 11 | pthread_barrierattr_t_ 4 12 | pthread_key_t_ 32 13 | pthread_cond_t_ 56 14 | pthread_condattr_t_ 4 15 | pthread_rwlock_t_ 40 16 | pthread_rwlockattr_t_ 4 17 | pthread_once_t_ 24 18 | ptw32_cleanup_t 24 19 | ptw32_mcs_node_t_ 32 20 | sched_param 4 21 | ------------------------------- 22 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/SIZES.VCE: -------------------------------------------------------------------------------- 1 | Sizes of pthreads-win32 structs 2 | ------------------------------- 3 | pthread_t 8 4 | ptw32_thread_t 96 5 | pthread_attr_t_ 28 6 | sem_t_ 12 7 | pthread_mutex_t_ 28 8 | pthread_mutexattr_t_ 12 9 | pthread_spinlock_t_ 8 10 | pthread_barrier_t_ 36 11 | pthread_barrierattr_t_ 4 12 | pthread_key_t_ 16 13 | pthread_cond_t_ 32 14 | pthread_condattr_t_ 4 15 | pthread_rwlock_t_ 28 16 | pthread_rwlockattr_t_ 4 17 | pthread_once_t_ 16 18 | ptw32_cleanup_t 12 19 | ptw32_mcs_node_t_ 16 20 | sched_param 4 21 | ------------------------------- 22 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/SIZES.VSE: -------------------------------------------------------------------------------- 1 | Sizes of pthreads-win32 structs 2 | ------------------------------- 3 | pthread_t 8 4 | ptw32_thread_t 96 5 | pthread_attr_t_ 28 6 | sem_t_ 12 7 | pthread_mutex_t_ 28 8 | pthread_mutexattr_t_ 12 9 | pthread_spinlock_t_ 8 10 | pthread_barrier_t_ 36 11 | pthread_barrierattr_t_ 4 12 | pthread_key_t_ 16 13 | pthread_cond_t_ 32 14 | pthread_condattr_t_ 4 15 | pthread_rwlock_t_ 28 16 | pthread_rwlockattr_t_ 4 17 | pthread_once_t_ 16 18 | ptw32_cleanup_t 12 19 | ptw32_mcs_node_t_ 16 20 | sched_param 4 21 | ------------------------------- 22 | -------------------------------------------------------------------------------- /third_party/pthread-w32/Nmakefile: -------------------------------------------------------------------------------- 1 | /* 2 | * nmake file for uwin pthread library 3 | */ 4 | 5 | VERSION = - 6 | CCFLAGS = -V -g $(CC.DLL) 7 | HAVE_PTW32_CONFIG_H == 1 8 | _MT == 1 9 | _timeb == timeb 10 | _ftime == ftime 11 | _errno == _ast_errno 12 | 13 | $(INCLUDEDIR) :INSTALLDIR: pthread.h sched.h 14 | 15 | pthread $(VERSION) :LIBRARY: attr.c barrier.c cancel.c cleanup.c condvar.c \ 16 | create.c dll.c exit.c fork.c global.c misc.c mutex.c private.c \ 17 | rwlock.c sched.c semaphore.c spin.c sync.c tsd.c nonportable.c 18 | 19 | :: ANNOUNCE CONTRIBUTORS COPYING.LIB ChangeLog FAQ GNUmakefile MAINTAINERS \ 20 | Makefile Makefile.in Makefile.vc NEWS PROGRESS README README.WinCE \ 21 | TODO WinCE-PORT install-sh errno.c tests tests.mk acconfig.h \ 22 | config.guess config.h.in config.sub configure configure.in signal.c \ 23 | README.CV README.NONPORTABLE pthread.dsp pthread.dsw 24 | 25 | -------------------------------------------------------------------------------- /src/PaletteOptimizer.h: -------------------------------------------------------------------------------- 1 | #ifndef PALETTE_OPTIMIZER_H 2 | #define PALETTE_OPTIMIZER_H 3 | 4 | #include "LPType.h" 5 | 6 | class PaletteOptimizer 7 | { 8 | public: 9 | explicit PaletteOptimizer(size_t width, size_t height); 10 | 11 | bool process32bit(buffer_t src); 12 | bool process24bit(buffer_t src); 13 | void process8bit(buffer_t src , palette_t palette, trans_t trans); 14 | 15 | buffer_t buffer() 16 | { 17 | return dest_; 18 | } 19 | palette_t palette() 20 | { 21 | return palette_; 22 | } 23 | trans_t trans() 24 | { 25 | return trans_; 26 | } 27 | size_t palette_size() 28 | { 29 | return palette_size_; 30 | } 31 | size_t trans_size() 32 | { 33 | return trans_size_; 34 | } 35 | 36 | private: 37 | buffer_t dest_; 38 | size_t size_; 39 | size_t pixelsize_; 40 | palette_t palette_; 41 | size_t palette_size_; 42 | trans_t trans_; 43 | size_t trans_size_; 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /third_party/libimagequant_build/SConscript: -------------------------------------------------------------------------------- 1 | Import('env') 2 | 3 | # Does AdrenoSDK use libimagequant? 4 | duplicate_symbols = [ 5 | 'pam_freeacolorhash', 6 | 'pam_freeacolorhist', 7 | 'pam_acolorhashtoacolorhist', 8 | 'pam_allocacolorhash', 9 | 'pam_computeacolorhash', 10 | 'mediancut' 11 | ] 12 | 13 | replaceflags = ["-D%(name)s=liq_%(name)s" % {"name": name} for name in duplicate_symbols] 14 | 15 | ccflags = ['-O3', '-m32', '-std=c99'] + replaceflags 16 | 17 | if env.GetOption('mingw32'): 18 | ccflags.append('-Duintptr_t=long') 19 | 20 | env.StaticLibrary( 21 | 'libimagequant', 22 | ['../libimagequant/lib/blur.c', 23 | '../libimagequant/lib/libimagequant.c', 24 | '../libimagequant/lib/mediancut.c', 25 | '../libimagequant/lib/mempool.c', 26 | '../libimagequant/lib/nearest.c', 27 | '../libimagequant/lib/pam.c', 28 | '../libimagequant/lib/viter.c'], 29 | LIBS=[], 30 | LIBPATH=[], 31 | CPPPATH=['../libimagequant/lib/'], 32 | CCFLAGS = ccflags 33 | ) 34 | -------------------------------------------------------------------------------- /LICENSE.rst: -------------------------------------------------------------------------------- 1 | The MIT License 2 | =============== 3 | 4 | Copyright (c) 2012 Yoshiki Shibukawa (DeNA Co.,Ltd, and ngmoco LLC) 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/README: -------------------------------------------------------------------------------- 1 | Running test cases in this directory 2 | ------------------------------------ 3 | 4 | These make scripts expect to be able to copy the dll, library 5 | and header files from this directory's parent directory, 6 | which should be the pthreads-win32 source directory. 7 | 8 | MS VC nmake 9 | ------------- 10 | 11 | Run the target corresponding to the DLL version being tested: 12 | 13 | nmake clean VC 14 | 15 | or: 16 | 17 | nmake clean VS 18 | 19 | 20 | GNU GCC make 21 | ------------ 22 | 23 | Run "make clean" and then "make". See the "Known bugs" section 24 | in ..\README. 25 | 26 | 27 | Writing Test Cases 28 | ------------------ 29 | 30 | Tests written in this test suite should behave in the following manner: 31 | 32 | * If a test fails, leave main() with a result of 1. 33 | 34 | * If a test succeeds, leave main() with a result of 0. 35 | 36 | * No diagnostic output should appear when the test is succeeding. 37 | Diagnostic output may be emitted if something in the test 38 | fails, to help determine the cause of the test failure. 39 | 40 | Notes: 41 | ------ 42 | 43 | Many test cases use knowledge of implementation internals which are supposed 44 | to be opaque to portable applications. 45 | -------------------------------------------------------------------------------- /third_party/libpng/TODO: -------------------------------------------------------------------------------- 1 | /* 2 | TODO - list of things to do for libpng: 3 | 4 | Final bug fixes. 5 | Better C++ wrapper/full C++ implementation? 6 | Fix problem with C++ and EXTERN "C". 7 | cHRM transformation. 8 | Remove setjmp/longjmp usage in favor of returning error codes. 9 | Add "grayscale->palette" transformation and "palette->grayscale" detection. 10 | Improved dithering. 11 | Multi-lingual error and warning message support. 12 | Complete sRGB transformation (presently it simply uses gamma=0.45455). 13 | Man pages for function calls. 14 | Better documentation. 15 | Better filter selection 16 | (counting huffman bits/precompression? filter inertia? filter costs?). 17 | Histogram creation. 18 | Text conversion between different code pages (Latin-1 -> Mac and DOS). 19 | Avoid building gamma tables whenever possible. 20 | Use greater precision when changing to linear gamma for compositing against 21 | background and doing rgb-to-gray transformation. 22 | Investigate pre-incremented loop counters and other loop constructions. 23 | Add interpolated method of handling interlacing. 24 | Switch to the simpler zlib (zlib/libpng) license if legally possible. 25 | Extend pngvalid.c to validate more of the libpng transformations. 26 | 27 | */ 28 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/Debug.plg: -------------------------------------------------------------------------------- 1 | 2 | 3 |
 4 | 

Build Log

5 |

6 | --------------------Configuration: Debug - Win32 Debug-------------------- 7 |

8 |

Command Lines

9 | Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP9.tmp" with contents 10 | [ 11 | /nologo /MDd /W3 /WX /Gm /ZI /Od /I ".." /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "CLEANUP_C" /FR"Debug/" /Fp"Debug/Debug.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c 12 | "E:\PTHREADS\pthreads.2\tests\semaphore1.c" 13 | ] 14 | Creating command line "cl.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP9.tmp" 15 | Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSPA.tmp" with contents 16 | [ 17 | kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib pthreadVC2d.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/Debug.pdb" /debug /machine:I386 /out:"Debug/Debug.exe" /pdbtype:sept /libpath:".." 18 | .\Debug\semaphore1.obj 19 | ] 20 | Creating command line "link.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSPA.tmp" 21 |

Output Window

22 | Compiling... 23 | semaphore1.c 24 | Linking... 25 | 26 | 27 | 28 |

Results

29 | Debug.exe - 0 error(s), 0 warning(s) 30 |
31 | 32 | 33 | -------------------------------------------------------------------------------- /src/MedianCut32bitQuantizer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "MedianCut32bitQuantizer.h" 3 | #include "libimagequant.h" 4 | 5 | void MedianCut32bitQuantizer::process_() 6 | { 7 | liq_attr *attr = liq_attr_create(); 8 | liq_set_speed(attr, 1); 9 | liq_image *image = liq_image_create_rgba(attr, reinterpret_cast(rawsrc_.get()), width_, height_, 0); 10 | liq_result *res = liq_quantize_image(attr, image); 11 | 12 | liq_set_dithering_level(res, 1); 13 | liq_write_remapped_image(res, image, reinterpret_cast(rawdest_.get()), width_ * height_); 14 | const liq_palette *pal = liq_get_palette(res); 15 | 16 | for (size_t i = 0; i < pal->count; ++i) 17 | { 18 | const liq_color& color = pal->entries[i]; 19 | palette_[i].red = color.r; 20 | palette_[i].green = color.g; 21 | palette_[i].blue = color.b; 22 | trans_[i] = color.a; 23 | } 24 | 25 | liq_attr_destroy(attr); 26 | liq_image_destroy(image); 27 | liq_result_destroy(res); 28 | } 29 | 30 | void median_cut_32bit_quantize(Image& image, PNGWriter& writer, bool hasAlphaChannel) 31 | { 32 | MedianCut32bitQuantizer quantizer(image.width(), image.height()); 33 | quantizer.process(image.image(), hasAlphaChannel); 34 | writer.process(quantizer.buffer(), quantizer.palette(), quantizer.trans(), true); 35 | } 36 | -------------------------------------------------------------------------------- /third_party/jpeg/maktjpeg.st: -------------------------------------------------------------------------------- 1 | ; Project file for Independent JPEG Group's software 2 | ; 3 | ; This project file is for Atari ST/STE/TT systems using Pure C or Turbo C. 4 | ; Thanks to Frank Moehle, B. Setzepfandt, and Guido Vollbeding. 5 | ; 6 | ; To use this file, rename it to jpegtran.prj. 7 | ; If you are using Turbo C, change filenames beginning with "pc..." to "tc..." 8 | ; Read installation instructions before trying to make the program! 9 | ; 10 | ; 11 | ; * * * Output file * * * 12 | jpegtran.ttp 13 | ; 14 | ; * * * COMPILER OPTIONS * * * 15 | .C[-P] ; absolute calls 16 | .C[-M] ; and no string merging, folks 17 | .C[-w-cln] ; no "constant is long" warnings 18 | .C[-w-par] ; no "parameter xxxx unused" 19 | .C[-w-rch] ; no "unreachable code" 20 | .C[-wsig] ; warn if significant digits may be lost 21 | = 22 | ; * * * * List of modules * * * * 23 | pcstart.o 24 | jpegtran.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h,transupp.h,jversion.h) 25 | cdjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) 26 | rdswitch.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) 27 | transupp.c (jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jpegint.h,jerror.h,transupp.h) 28 | libjpeg.lib ; built by libjpeg.prj 29 | pcstdlib.lib ; standard library 30 | pcextlib.lib ; extended library 31 | -------------------------------------------------------------------------------- /src/JPEGReader.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "JPEGReader.h" 4 | 5 | 6 | JPEGReader::JPEGReader(const char* filepath) : Image() 7 | { 8 | jpeg_create_decompress(&jpeginfo_); 9 | jpeginfo_.err = jpeg_std_error(&jpegerr_); 10 | 11 | FILE* fp = fopen(filepath, "rb"); 12 | if (!fp) 13 | { 14 | std::cout << "Input file not found: " << filepath << std::endl; 15 | return; 16 | } 17 | jpeg_stdio_src(&jpeginfo_, fp); 18 | jpeg_read_header(&jpeginfo_, TRUE); 19 | jpeg_start_decompress(&jpeginfo_); 20 | 21 | if (jpeginfo_.out_color_components != 3) 22 | { 23 | std::cout << "This program support only 24 bit image." << std::endl; 24 | fclose(fp); 25 | return; 26 | } 27 | width_ = jpeginfo_.output_width; 28 | height_ = jpeginfo_.output_height; 29 | 30 | alloc(3); 31 | 32 | while(jpeginfo_.output_scanline < jpeginfo_.output_height) 33 | { 34 | jpeg_read_scanlines(&jpeginfo_, 35 | image().get() + jpeginfo_.output_scanline, 36 | jpeginfo_.output_height - jpeginfo_.output_scanline 37 | ); 38 | } 39 | 40 | jpeg_finish_decompress(&jpeginfo_); 41 | fclose(fp); 42 | valid_ = true; 43 | } 44 | 45 | JPEGReader::~JPEGReader() 46 | { 47 | destroy(); 48 | } 49 | 50 | void JPEGReader::destroy() 51 | { 52 | jpeg_destroy_decompress(&jpeginfo_); 53 | } 54 | -------------------------------------------------------------------------------- /third_party/jpeg/jconfig.h: -------------------------------------------------------------------------------- 1 | /* jconfig.h. Generated automatically by configure. */ 2 | /* jconfig.cfg --- source file edited by configure script */ 3 | /* see jconfig.doc for explanations */ 4 | 5 | #define HAVE_PROTOTYPES 6 | #define HAVE_UNSIGNED_CHAR 7 | #define HAVE_UNSIGNED_SHORT 8 | #undef void 9 | #undef const 10 | #undef CHAR_IS_UNSIGNED 11 | #define HAVE_STDDEF_H 12 | #define HAVE_STDLIB_H 13 | #undef NEED_BSD_STRINGS 14 | #undef NEED_SYS_TYPES_H 15 | #undef NEED_FAR_POINTERS 16 | #undef NEED_SHORT_EXTERNAL_NAMES 17 | /* Define this if you get warnings about undefined structures. */ 18 | #undef INCOMPLETE_TYPES_BROKEN 19 | 20 | #ifdef JPEG_INTERNALS 21 | 22 | #undef RIGHT_SHIFT_IS_UNSIGNED 23 | #define INLINE __inline__ 24 | /* These are for configuring the JPEG memory manager. */ 25 | #undef DEFAULT_MAX_MEM 26 | #undef NO_MKTEMP 27 | 28 | #endif /* JPEG_INTERNALS */ 29 | 30 | #ifdef JPEG_CJPEG_DJPEG 31 | 32 | #define BMP_SUPPORTED /* BMP image file format */ 33 | #define GIF_SUPPORTED /* GIF image file format */ 34 | #define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ 35 | #undef RLE_SUPPORTED /* Utah RLE image file format */ 36 | #define TARGA_SUPPORTED /* Targa image file format */ 37 | 38 | #undef TWO_FILE_COMMANDLINE 39 | #undef NEED_SIGNAL_CATCHER 40 | #undef DONT_USE_B_MODE 41 | 42 | /* Define this if you want percent-done progress reports from cjpeg/djpeg. */ 43 | #undef PROGRESS_REPORT 44 | 45 | #endif /* JPEG_CJPEG_DJPEG */ 46 | -------------------------------------------------------------------------------- /src/PNGWriter.h: -------------------------------------------------------------------------------- 1 | #ifndef PNGWRITER_H 2 | #define PNGWRITER_H 3 | 4 | #include 5 | #include "LPType.h" 6 | #include "Image.h" 7 | 8 | class Buffer; 9 | 10 | class PNGWriter 11 | { 12 | public: 13 | PNGWriter(Image& image, bool has_alpha, size_t optimize, bool verbose) 14 | : width_(0), height_(0), file_size_(0), 15 | has_alpha_(has_alpha), index_(false), optimize_(optimize), verbose_(verbose), valid_(0) 16 | { 17 | width_ = image.width(); 18 | height_ = image.height(); 19 | } 20 | ~PNGWriter(); 21 | void process(buffer_t raw_buffer); 22 | void process(buffer_t raw_buffer, palette_t palette, trans_t trans, bool palette_optimize = false); 23 | void process(buffer_t raw_buffer, bool shrinkChannel); 24 | void write(const char* filepath); 25 | void compress(size_t parameter_index, Buffer* buffer); 26 | 27 | private: 28 | buffer_t raw_buffer_; 29 | rows_t image_rows_; 30 | buffer_t file_content_; 31 | palette_t palette_; 32 | trans_t trans_; 33 | size_t width_; 34 | size_t height_; 35 | size_t file_size_; 36 | size_t palette_size_; 37 | size_t trans_size_; 38 | bool has_alpha_; 39 | bool index_; 40 | size_t optimize_; 41 | bool verbose_; 42 | bool valid_; 43 | 44 | void process_(); 45 | bool can_convert_index_color_(buffer_t raw_buffer); 46 | int optimizeWithOptions_(size_t start_paramter, size_t end_parameter, bool show_result); 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /third_party/zlib/zlib.map: -------------------------------------------------------------------------------- 1 | ZLIB_1.2.0 { 2 | global: 3 | compressBound; 4 | deflateBound; 5 | inflateBack; 6 | inflateBackEnd; 7 | inflateBackInit_; 8 | inflateCopy; 9 | local: 10 | deflate_copyright; 11 | inflate_copyright; 12 | inflate_fast; 13 | inflate_table; 14 | zcalloc; 15 | zcfree; 16 | z_errmsg; 17 | gz_error; 18 | gz_intmax; 19 | _*; 20 | }; 21 | 22 | ZLIB_1.2.0.2 { 23 | gzclearerr; 24 | gzungetc; 25 | zlibCompileFlags; 26 | } ZLIB_1.2.0; 27 | 28 | ZLIB_1.2.0.8 { 29 | deflatePrime; 30 | } ZLIB_1.2.0.2; 31 | 32 | ZLIB_1.2.2 { 33 | adler32_combine; 34 | crc32_combine; 35 | deflateSetHeader; 36 | inflateGetHeader; 37 | } ZLIB_1.2.0.8; 38 | 39 | ZLIB_1.2.2.3 { 40 | deflateTune; 41 | gzdirect; 42 | } ZLIB_1.2.2; 43 | 44 | ZLIB_1.2.2.4 { 45 | inflatePrime; 46 | } ZLIB_1.2.2.3; 47 | 48 | ZLIB_1.2.3.3 { 49 | adler32_combine64; 50 | crc32_combine64; 51 | gzopen64; 52 | gzseek64; 53 | gztell64; 54 | inflateUndermine; 55 | } ZLIB_1.2.2.4; 56 | 57 | ZLIB_1.2.3.4 { 58 | inflateReset2; 59 | inflateMark; 60 | } ZLIB_1.2.3.3; 61 | 62 | ZLIB_1.2.3.5 { 63 | gzbuffer; 64 | gzoffset; 65 | gzoffset64; 66 | gzclose_r; 67 | gzclose_w; 68 | } ZLIB_1.2.3.4; 69 | 70 | ZLIB_1.2.5.1 { 71 | deflatePending; 72 | } ZLIB_1.2.3.5; 73 | 74 | ZLIB_1.2.5.2 { 75 | deflateResetKeep; 76 | gzgetc_; 77 | inflateResetKeep; 78 | } ZLIB_1.2.5.1; 79 | -------------------------------------------------------------------------------- /third_party/pthread-w32/fork.c: -------------------------------------------------------------------------------- 1 | /* 2 | * fork.c 3 | * 4 | * Description: 5 | * Implementation of fork() for POSIX threads. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | 38 | #include "pthread.h" 39 | #include "implement.h" 40 | -------------------------------------------------------------------------------- /third_party/pthread-w32/manual/pthread_equal.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | PTHREAD_EQUAL(3) manual page 7 | 8 | 9 | Table of Contents

10 | 11 |

12 |

Name

13 | pthread_equal - compare two thread identifiers 14 |

15 |

Synopsis

16 | #include <pthread.h> 17 | 18 |

int pthread_equal(pthread_t thread1, pthread_t thread2); 19 |

20 |

Description

21 | pthread_equal 22 | determines if two thread identifiers refer to the same thread. 23 |

24 |

Return Value

25 | A 26 | non-zero value is returned if thread1 and thread2 refer to the same thread. 27 | Otherwise, 0 is returned. 28 |

29 |

Author

30 | Xavier Leroy <Xavier.Leroy@inria.fr> 31 |

32 |

See Also

33 | pthread_self(3) 34 | . 35 |

36 | 37 |


38 | Table of Contents

39 |

47 | 48 | 49 | -------------------------------------------------------------------------------- /src/Quantizer.h: -------------------------------------------------------------------------------- 1 | #ifndef QUANTIZER_H 2 | #define QUANTIZER_H 3 | 4 | #include 5 | #include "LPType.h" 6 | #include "Image.h" 7 | 8 | 9 | class Quantizer 10 | { 11 | public: 12 | explicit Quantizer(size_t width, size_t height) 13 | : width_(width), height_(height) 14 | { 15 | rawsrc_.reset(new unsigned char[4 * width * height]); 16 | rawdest_.reset(new unsigned char[width * height]); 17 | src_.reset(new unsigned char*[height]); 18 | for (size_t i = 0; i < height_; ++i) 19 | { 20 | src_[i] = rawsrc_.get() + (i * width * 4); 21 | } 22 | palette_.reset(new png_color[256]); 23 | trans_.reset(new unsigned char[256]); 24 | }; 25 | virtual ~Quantizer() {} 26 | 27 | void process(rows_t src, bool hasAlphaChannel) 28 | { 29 | if (hasAlphaChannel) 30 | { 31 | Image::copy_4_to_4(width_, height_, src, src_); 32 | } 33 | else 34 | { 35 | Image::copy_3_to_4(width_, height_, src, src_); 36 | } 37 | process_(); 38 | } 39 | void process(buffer_t src, bool hasAlphaChannel) 40 | { 41 | if (hasAlphaChannel) 42 | { 43 | Image::copy_4_to_4(width_, height_, src, rawsrc_); 44 | } 45 | else 46 | { 47 | Image::copy_3_to_4(width_, height_, src, rawsrc_); 48 | } 49 | process_(); 50 | } 51 | buffer_t buffer() 52 | { 53 | return rawdest_; 54 | }; 55 | palette_t palette() 56 | { 57 | return palette_; 58 | }; 59 | trans_t trans() 60 | { 61 | return trans_; 62 | } 63 | 64 | protected: 65 | rows_t src_; 66 | buffer_t rawsrc_; 67 | buffer_t rawdest_; 68 | size_t width_, height_; 69 | palette_t palette_; 70 | trans_t trans_; 71 | virtual void process_() {} 72 | }; 73 | 74 | #endif 75 | 76 | -------------------------------------------------------------------------------- /third_party/pthread-w32/sync.c: -------------------------------------------------------------------------------- 1 | /* 2 | * sync.c 3 | * 4 | * Description: 5 | * This translation unit implements functions related to thread 6 | * synchronisation. 7 | * 8 | * -------------------------------------------------------------------------- 9 | * 10 | * Pthreads-win32 - POSIX Threads Library for Win32 11 | * Copyright(C) 1998 John E. Bossom 12 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 13 | * 14 | * Contact Email: rpj@callisto.canberra.edu.au 15 | * 16 | * The current list of contributors is contained 17 | * in the file CONTRIBUTORS included with the source 18 | * code distribution. The list can also be seen at the 19 | * following World Wide Web location: 20 | * http://sources.redhat.com/pthreads-win32/contributors.html 21 | * 22 | * This library is free software; you can redistribute it and/or 23 | * modify it under the terms of the GNU Lesser General Public 24 | * License as published by the Free Software Foundation; either 25 | * version 2 of the License, or (at your option) any later version. 26 | * 27 | * This library is distributed in the hope that it will be useful, 28 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 29 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 30 | * Lesser General Public License for more details. 31 | * 32 | * You should have received a copy of the GNU Lesser General Public 33 | * License along with this library in the file COPYING.LIB; 34 | * if not, write to the Free Software Foundation, Inc., 35 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 36 | */ 37 | 38 | #include "pthread.h" 39 | #include "implement.h" 40 | 41 | 42 | #include "pthread_detach.c" 43 | #include "pthread_join.c" 44 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/sizes.c: -------------------------------------------------------------------------------- 1 | #define _WIN32_WINNT 0x400 2 | 3 | #include "test.h" 4 | #include "../implement.h" 5 | 6 | int 7 | main() 8 | { 9 | printf("Sizes of pthreads-win32 structs\n"); 10 | printf("-------------------------------\n"); 11 | printf("%30s %4d\n", "pthread_t", (int)sizeof(pthread_t)); 12 | printf("%30s %4d\n", "ptw32_thread_t", (int)sizeof(ptw32_thread_t)); 13 | printf("%30s %4d\n", "pthread_attr_t_", (int)sizeof(struct pthread_attr_t_)); 14 | printf("%30s %4d\n", "sem_t_", (int)sizeof(struct sem_t_)); 15 | printf("%30s %4d\n", "pthread_mutex_t_", (int)sizeof(struct pthread_mutex_t_)); 16 | printf("%30s %4d\n", "pthread_mutexattr_t_", (int)sizeof(struct pthread_mutexattr_t_)); 17 | printf("%30s %4d\n", "pthread_spinlock_t_", (int)sizeof(struct pthread_spinlock_t_)); 18 | printf("%30s %4d\n", "pthread_barrier_t_", (int)sizeof(struct pthread_barrier_t_)); 19 | printf("%30s %4d\n", "pthread_barrierattr_t_", (int)sizeof(struct pthread_barrierattr_t_)); 20 | printf("%30s %4d\n", "pthread_key_t_", (int)sizeof(struct pthread_key_t_)); 21 | printf("%30s %4d\n", "pthread_cond_t_", (int)sizeof(struct pthread_cond_t_)); 22 | printf("%30s %4d\n", "pthread_condattr_t_", (int)sizeof(struct pthread_condattr_t_)); 23 | printf("%30s %4d\n", "pthread_rwlock_t_", (int)sizeof(struct pthread_rwlock_t_)); 24 | printf("%30s %4d\n", "pthread_rwlockattr_t_", (int)sizeof(struct pthread_rwlockattr_t_)); 25 | printf("%30s %4d\n", "pthread_once_t_", (int)sizeof(struct pthread_once_t_)); 26 | printf("%30s %4d\n", "ptw32_cleanup_t", (int)sizeof(struct ptw32_cleanup_t)); 27 | printf("%30s %4d\n", "ptw32_mcs_node_t_", (int)sizeof(struct ptw32_mcs_node_t_)); 28 | printf("%30s %4d\n", "sched_param", (int)sizeof(struct sched_param)); 29 | printf("-------------------------------\n"); 30 | 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /third_party/jpeg/makcjpeg.st: -------------------------------------------------------------------------------- 1 | ; Project file for Independent JPEG Group's software 2 | ; 3 | ; This project file is for Atari ST/STE/TT systems using Pure C or Turbo C. 4 | ; Thanks to Frank Moehle, B. Setzepfandt, and Guido Vollbeding. 5 | ; 6 | ; To use this file, rename it to cjpeg.prj. 7 | ; If you are using Turbo C, change filenames beginning with "pc..." to "tc..." 8 | ; Read installation instructions before trying to make the program! 9 | ; 10 | ; 11 | ; * * * Output file * * * 12 | cjpeg.ttp 13 | ; 14 | ; * * * COMPILER OPTIONS * * * 15 | .C[-P] ; absolute calls 16 | .C[-M] ; and no string merging, folks 17 | .C[-w-cln] ; no "constant is long" warnings 18 | .C[-w-par] ; no "parameter xxxx unused" 19 | .C[-w-rch] ; no "unreachable code" 20 | .C[-wsig] ; warn if significant digits may be lost 21 | = 22 | ; * * * * List of modules * * * * 23 | pcstart.o 24 | cjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h,jversion.h) 25 | cdjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) 26 | rdswitch.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) 27 | rdppm.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) 28 | rdgif.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) 29 | rdtarga.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) 30 | rdbmp.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) 31 | rdrle.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) 32 | libjpeg.lib ; built by libjpeg.prj 33 | pcfltlib.lib ; floating point library 34 | ; the float library can be omitted if you've turned off DCT_FLOAT_SUPPORTED 35 | pcstdlib.lib ; standard library 36 | pcextlib.lib ; extended library 37 | -------------------------------------------------------------------------------- /third_party/jpeg/makdjpeg.st: -------------------------------------------------------------------------------- 1 | ; Project file for Independent JPEG Group's software 2 | ; 3 | ; This project file is for Atari ST/STE/TT systems using Pure C or Turbo C. 4 | ; Thanks to Frank Moehle, B. Setzepfandt, and Guido Vollbeding. 5 | ; 6 | ; To use this file, rename it to djpeg.prj. 7 | ; If you are using Turbo C, change filenames beginning with "pc..." to "tc..." 8 | ; Read installation instructions before trying to make the program! 9 | ; 10 | ; 11 | ; * * * Output file * * * 12 | djpeg.ttp 13 | ; 14 | ; * * * COMPILER OPTIONS * * * 15 | .C[-P] ; absolute calls 16 | .C[-M] ; and no string merging, folks 17 | .C[-w-cln] ; no "constant is long" warnings 18 | .C[-w-par] ; no "parameter xxxx unused" 19 | .C[-w-rch] ; no "unreachable code" 20 | .C[-wsig] ; warn if significant digits may be lost 21 | = 22 | ; * * * * List of modules * * * * 23 | pcstart.o 24 | djpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h,jversion.h) 25 | cdjpeg.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) 26 | rdcolmap.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) 27 | wrppm.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) 28 | wrgif.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) 29 | wrtarga.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) 30 | wrbmp.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) 31 | wrrle.c (cdjpeg.h,jinclude.h,jconfig.h,jpeglib.h,jmorecfg.h,jerror.h,cderror.h) 32 | libjpeg.lib ; built by libjpeg.prj 33 | pcfltlib.lib ; floating point library 34 | ; the float library can be omitted if you've turned off DCT_FLOAT_SUPPORTED 35 | pcstdlib.lib ; standard library 36 | pcextlib.lib ; extended library 37 | -------------------------------------------------------------------------------- /third_party/pthread-w32/pthread_getconcurrency.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pthread_getconcurrency.c 3 | * 4 | * Description: 5 | * This translation unit implements miscellaneous thread functions. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | 40 | 41 | int 42 | pthread_getconcurrency (void) 43 | { 44 | return ptw32_concurrency; 45 | } 46 | -------------------------------------------------------------------------------- /third_party/pthread-w32/exit.c: -------------------------------------------------------------------------------- 1 | /* 2 | * exit.c 3 | * 4 | * Description: 5 | * This translation unit implements routines associated with exiting from 6 | * a thread. 7 | * 8 | * -------------------------------------------------------------------------- 9 | * 10 | * Pthreads-win32 - POSIX Threads Library for Win32 11 | * Copyright(C) 1998 John E. Bossom 12 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 13 | * 14 | * Contact Email: rpj@callisto.canberra.edu.au 15 | * 16 | * The current list of contributors is contained 17 | * in the file CONTRIBUTORS included with the source 18 | * code distribution. The list can also be seen at the 19 | * following World Wide Web location: 20 | * http://sources.redhat.com/pthreads-win32/contributors.html 21 | * 22 | * This library is free software; you can redistribute it and/or 23 | * modify it under the terms of the GNU Lesser General Public 24 | * License as published by the Free Software Foundation; either 25 | * version 2 of the License, or (at your option) any later version. 26 | * 27 | * This library is distributed in the hope that it will be useful, 28 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 29 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 30 | * Lesser General Public License for more details. 31 | * 32 | * You should have received a copy of the GNU Lesser General Public 33 | * License along with this library in the file COPYING.LIB; 34 | * if not, write to the Free Software Foundation, Inc., 35 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 36 | */ 37 | 38 | #include "pthread.h" 39 | #include "implement.h" 40 | #if ! defined(_UWIN) && ! defined(WINCE) 41 | # include 42 | #endif 43 | 44 | #include "pthread_exit.c" 45 | -------------------------------------------------------------------------------- /third_party/pthread-w32/cancel.c: -------------------------------------------------------------------------------- 1 | /* 2 | * cancel.c 3 | * 4 | * Description: 5 | * POSIX thread functions related to thread cancellation. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | 40 | 41 | #include "pthread_setcancelstate.c" 42 | #include "pthread_setcanceltype.c" 43 | #include "pthread_testcancel.c" 44 | #include "pthread_cancel.c" 45 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tsd.c: -------------------------------------------------------------------------------- 1 | /* 2 | * tsd.c 3 | * 4 | * Description: 5 | * POSIX thread functions which implement thread-specific data (TSD). 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | 40 | 41 | #include "pthread_key_create.c" 42 | #include "pthread_key_delete.c" 43 | #include "pthread_setspecific.c" 44 | #include "pthread_getspecific.c" 45 | -------------------------------------------------------------------------------- /src/BitChanger.h: -------------------------------------------------------------------------------- 1 | #ifndef BIT_CHANGER_H 2 | #define BIT_CHANGER_H 3 | 4 | #include 5 | #include "LPType.h" 6 | #include "Image.h" 7 | 8 | class BitChanger : public Image 9 | { 10 | public: 11 | explicit BitChanger(size_t width, size_t height, bool useAlpha, buffer_t src) 12 | : Image() 13 | { 14 | size_t size = pow(2, ceil(log2(fmax(width, height)))); 15 | width_ = size; 16 | height_ = size; 17 | 18 | alloc(4); 19 | 20 | int bytePerPixel = (useAlpha) ? 4 : 3; 21 | 22 | for (size_t y = 0; y < size; y++) 23 | { 24 | for (size_t x = 0; x < size; x++) 25 | { 26 | if (y < height && x < width) 27 | { 28 | size_t src_offset = y * width + x; 29 | size_t dest_offset = y * size + x; 30 | data_[dest_offset * 4] = src[src_offset * bytePerPixel]; 31 | data_[dest_offset * 4 + 1] = src[src_offset * bytePerPixel + 1]; 32 | data_[dest_offset * 4 + 2] = src[src_offset * bytePerPixel + 2]; 33 | if (useAlpha) 34 | { 35 | data_[dest_offset * 4 + 3] = src[src_offset * bytePerPixel + 3]; 36 | } 37 | else 38 | { 39 | data_[dest_offset * 4 + 3] = 255; 40 | } 41 | } 42 | else 43 | { 44 | size_t dest_offset = y * size + x; 45 | data_[dest_offset * 4] = 0; 46 | data_[dest_offset * 4 + 1] = 0; 47 | data_[dest_offset * 4 + 2] = 0; 48 | data_[dest_offset * 4 + 3] = 0; 49 | } 50 | } 51 | } 52 | valid_ = true; 53 | } 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /third_party/pthread-w32/pthread_getunique_np.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pthread_getunique_np.c 3 | * 4 | * Description: 5 | * This translation unit implements non-portable thread functions. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | 40 | /* 41 | * 42 | */ 43 | unsigned __int64 44 | pthread_getunique_np (pthread_t thread) 45 | { 46 | return ((ptw32_thread_t*)thread.p)->seqNumber; 47 | } 48 | -------------------------------------------------------------------------------- /third_party/pthread-w32/pthread_mutexattr_setkind_np.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pthread_mutexattr_setkind_np.c 3 | * 4 | * Description: 5 | * This translation unit implements non-portable thread functions. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | 40 | int 41 | pthread_mutexattr_setkind_np (pthread_mutexattr_t * attr, int kind) 42 | { 43 | return pthread_mutexattr_settype (attr, kind); 44 | } 45 | -------------------------------------------------------------------------------- /third_party/pthread-w32/pthread_mutexattr_getkind_np.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pthread_mutexattr_getkind_np.c 3 | * 4 | * Description: 5 | * This translation unit implements non-portable thread functions. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | 40 | int 41 | pthread_mutexattr_getkind_np (pthread_mutexattr_t * attr, int *kind) 42 | { 43 | return pthread_mutexattr_gettype (attr, kind); 44 | } 45 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/exit1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Test for pthread_exit(). 3 | * 4 | * 5 | * -------------------------------------------------------------------------- 6 | * 7 | * Pthreads-win32 - POSIX Threads Library for Win32 8 | * Copyright(C) 1998 John E. Bossom 9 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 10 | * 11 | * Contact Email: rpj@callisto.canberra.edu.au 12 | * 13 | * The current list of contributors is contained 14 | * in the file CONTRIBUTORS included with the source 15 | * code distribution. The list can also be seen at the 16 | * following World Wide Web location: 17 | * http://sources.redhat.com/pthreads-win32/contributors.html 18 | * 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; either 22 | * version 2 of the License, or (at your option) any later version. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library in the file COPYING.LIB; 31 | * if not, write to the Free Software Foundation, Inc., 32 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33 | * 34 | * -------------------------------------------------------------------------- 35 | * 36 | * Depends on API functions: None. 37 | */ 38 | 39 | #include "test.h" 40 | 41 | int 42 | main(int argc, char * argv[]) 43 | { 44 | /* A simple test first. */ 45 | pthread_exit((void *) 0); 46 | 47 | /* Not reached */ 48 | assert(0); 49 | return 0; 50 | } 51 | -------------------------------------------------------------------------------- /third_party/pthread-w32/spin.c: -------------------------------------------------------------------------------- 1 | /* 2 | * spin.c 3 | * 4 | * Description: 5 | * This translation unit implements spin lock primitives. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | 40 | 41 | #include "ptw32_spinlock_check_need_init.c" 42 | #include "pthread_spin_init.c" 43 | #include "pthread_spin_destroy.c" 44 | #include "pthread_spin_lock.c" 45 | #include "pthread_spin_unlock.c" 46 | #include "pthread_spin_trylock.c" 47 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/delay1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * delay1.c 3 | * 4 | * 5 | * -------------------------------------------------------------------------- 6 | * 7 | * Pthreads-win32 - POSIX Threads Library for Win32 8 | * Copyright(C) 1998 John E. Bossom 9 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 10 | * 11 | * Contact Email: rpj@callisto.canberra.edu.au 12 | * 13 | * The current list of contributors is contained 14 | * in the file CONTRIBUTORS included with the source 15 | * code distribution. The list can also be seen at the 16 | * following World Wide Web location: 17 | * http://sources.redhat.com/pthreads-win32/contributors.html 18 | * 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; either 22 | * version 2 of the License, or (at your option) any later version. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library in the file COPYING.LIB; 31 | * if not, write to the Free Software Foundation, Inc., 32 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33 | * 34 | * -------------------------------------------------------------------------- 35 | * 36 | * Depends on API functions: 37 | * pthread_delay_np 38 | */ 39 | 40 | #include "test.h" 41 | 42 | int 43 | main(int argc, char * argv[]) 44 | { 45 | struct timespec interval = {1L, 500000000L}; 46 | 47 | assert(pthread_delay_np(&interval) == 0); 48 | 49 | return 0; 50 | } 51 | 52 | -------------------------------------------------------------------------------- /third_party/pthread-w32/pthread_setconcurrency.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pthread_setconcurrency.c 3 | * 4 | * Description: 5 | * This translation unit implements miscellaneous thread functions. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | 40 | 41 | int 42 | pthread_setconcurrency (int level) 43 | { 44 | if (level < 0) 45 | { 46 | return EINVAL; 47 | } 48 | else 49 | { 50 | ptw32_concurrency = level; 51 | return 0; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /third_party/pthread-w32/ptw32_is_attr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ptw32_is_attr.c 3 | * 4 | * Description: 5 | * This translation unit implements operations on thread attribute objects. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | 40 | int 41 | ptw32_is_attr (const pthread_attr_t * attr) 42 | { 43 | /* Return 0 if the attr object is valid, non-zero otherwise. */ 44 | 45 | return (attr == NULL || 46 | *attr == NULL || (*attr)->valid != PTW32_ATTR_VALID); 47 | } 48 | -------------------------------------------------------------------------------- /third_party/pthread-w32/barrier.c: -------------------------------------------------------------------------------- 1 | /* 2 | * barrier.c 3 | * 4 | * Description: 5 | * This translation unit implements barrier primitives. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | 40 | 41 | #include "pthread_barrier_init.c" 42 | #include "pthread_barrier_destroy.c" 43 | #include "pthread_barrier_wait.c" 44 | #include "pthread_barrierattr_init.c" 45 | #include "pthread_barrierattr_destroy.c" 46 | #include "pthread_barrierattr_getpshared.c" 47 | #include "pthread_barrierattr_setpshared.c" 48 | -------------------------------------------------------------------------------- /third_party/pthread-w32/ptw32_calloc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ptw32_calloc.c 3 | * 4 | * Description: 5 | * This translation unit implements miscellaneous thread functions. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | 40 | 41 | #if defined(NEED_CALLOC) 42 | void * 43 | ptw32_calloc (size_t n, size_t s) 44 | { 45 | unsigned int m = n * s; 46 | void *p; 47 | 48 | p = malloc (m); 49 | if (p == NULL) 50 | return NULL; 51 | 52 | memset (p, 0, m); 53 | 54 | return p; 55 | } 56 | #endif 57 | -------------------------------------------------------------------------------- /third_party/pthread-w32/misc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * misc.c 3 | * 4 | * Description: 5 | * This translation unit implements miscellaneous thread functions. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | 40 | 41 | #include "pthread_kill.c" 42 | #include "pthread_once.c" 43 | #include "pthread_self.c" 44 | #include "pthread_equal.c" 45 | #include "pthread_setconcurrency.c" 46 | #include "pthread_getconcurrency.c" 47 | #include "ptw32_new.c" 48 | #include "ptw32_calloc.c" 49 | #include "ptw32_reuse.c" 50 | #include "w32_CancelableWait.c" 51 | -------------------------------------------------------------------------------- /third_party/pthread-w32/pthread_attr_getinheritsched.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pthread_attr_getinheritsched.c 3 | * 4 | * Description: 5 | * POSIX thread functions that deal with thread scheduling. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | #include "sched.h" 40 | 41 | int 42 | pthread_attr_getinheritsched (const pthread_attr_t * attr, int *inheritsched) 43 | { 44 | if (ptw32_is_attr (attr) != 0 || inheritsched == NULL) 45 | { 46 | return EINVAL; 47 | } 48 | 49 | *inheritsched = (*attr)->inheritsched; 50 | return 0; 51 | } 52 | -------------------------------------------------------------------------------- /third_party/pthread-w32/pthread_attr_setschedpolicy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pthread_attr_setschedpolicy.c 3 | * 4 | * Description: 5 | * POSIX thread functions that deal with thread scheduling. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | #include "sched.h" 40 | 41 | int 42 | pthread_attr_setschedpolicy (pthread_attr_t * attr, int policy) 43 | { 44 | if (ptw32_is_attr (attr) != 0) 45 | { 46 | return EINVAL; 47 | } 48 | 49 | if (policy != SCHED_OTHER) 50 | { 51 | return ENOTSUP; 52 | } 53 | 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /third_party/pthread-w32/pthread_num_processors_np.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pthread_num_processors_np.c 3 | * 4 | * Description: 5 | * This translation unit implements non-portable thread functions. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | 40 | /* 41 | * pthread_num_processors_np() 42 | * 43 | * Get the number of CPUs available to the process. 44 | */ 45 | int 46 | pthread_num_processors_np (void) 47 | { 48 | int count; 49 | 50 | if (ptw32_getprocessors (&count) != 0) 51 | { 52 | count = 1; 53 | } 54 | 55 | return (count); 56 | } 57 | -------------------------------------------------------------------------------- /third_party/pthread-w32/nonportable.c: -------------------------------------------------------------------------------- 1 | /* 2 | * nonportable.c 3 | * 4 | * Description: 5 | * This translation unit implements non-portable thread functions. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | 40 | #include "pthread_mutexattr_setkind_np.c" 41 | #include "pthread_mutexattr_getkind_np.c" 42 | #include "pthread_getw32threadhandle_np.c" 43 | #include "pthread_getunique_np.c" 44 | #include "pthread_delay_np.c" 45 | #include "pthread_num_processors_np.c" 46 | #include "pthread_win32_attach_detach_np.c" 47 | #include "pthread_timechange_handler_np.c" 48 | -------------------------------------------------------------------------------- /third_party/pthread-w32/pthread_attr_getschedparam.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pthread_attr_getschedparam.c 3 | * 4 | * Description: 5 | * POSIX thread functions that deal with thread scheduling. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | #include "sched.h" 40 | 41 | int 42 | pthread_attr_getschedparam (const pthread_attr_t * attr, 43 | struct sched_param *param) 44 | { 45 | if (ptw32_is_attr (attr) != 0 || param == NULL) 46 | { 47 | return EINVAL; 48 | } 49 | 50 | memcpy (param, &(*attr)->param, sizeof (*param)); 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /third_party/pthread-w32/pthread_mutexattr_gettype.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pthread_mutexattr_gettype.c 3 | * 4 | * Description: 5 | * This translation unit implements mutual exclusion (mutex) primitives. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | 40 | 41 | int 42 | pthread_mutexattr_gettype (const pthread_mutexattr_t * attr, int *kind) 43 | { 44 | int result = 0; 45 | 46 | if (attr != NULL && *attr != NULL && kind != NULL) 47 | { 48 | *kind = (*attr)->kind; 49 | } 50 | else 51 | { 52 | result = EINVAL; 53 | } 54 | 55 | return (result); 56 | } 57 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/barrier1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * barrier1.c 3 | * 4 | * 5 | * -------------------------------------------------------------------------- 6 | * 7 | * Pthreads-win32 - POSIX Threads Library for Win32 8 | * Copyright(C) 1998 John E. Bossom 9 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 10 | * 11 | * Contact Email: rpj@callisto.canberra.edu.au 12 | * 13 | * The current list of contributors is contained 14 | * in the file CONTRIBUTORS included with the source 15 | * code distribution. The list can also be seen at the 16 | * following World Wide Web location: 17 | * http://sources.redhat.com/pthreads-win32/contributors.html 18 | * 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; either 22 | * version 2 of the License, or (at your option) any later version. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library in the file COPYING.LIB; 31 | * if not, write to the Free Software Foundation, Inc., 32 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33 | * 34 | * -------------------------------------------------------------------------- 35 | * 36 | * Create a barrier object and then destroy it. 37 | * 38 | */ 39 | 40 | #include "test.h" 41 | 42 | pthread_barrier_t barrier = NULL; 43 | 44 | int 45 | main() 46 | { 47 | assert(barrier == NULL); 48 | 49 | assert(pthread_barrier_init(&barrier, NULL, 1) == 0); 50 | 51 | assert(barrier != NULL); 52 | 53 | assert(pthread_barrier_destroy(&barrier) == 0); 54 | 55 | assert(barrier == NULL); 56 | 57 | return 0; 58 | } 59 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/barrier2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * barrier2.c 3 | * 4 | * 5 | * -------------------------------------------------------------------------- 6 | * 7 | * Pthreads-win32 - POSIX Threads Library for Win32 8 | * Copyright(C) 1998 John E. Bossom 9 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 10 | * 11 | * Contact Email: rpj@callisto.canberra.edu.au 12 | * 13 | * The current list of contributors is contained 14 | * in the file CONTRIBUTORS included with the source 15 | * code distribution. The list can also be seen at the 16 | * following World Wide Web location: 17 | * http://sources.redhat.com/pthreads-win32/contributors.html 18 | * 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; either 22 | * version 2 of the License, or (at your option) any later version. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library in the file COPYING.LIB; 31 | * if not, write to the Free Software Foundation, Inc., 32 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33 | * 34 | * -------------------------------------------------------------------------- 35 | * 36 | * Declare a single barrier object, wait on it, 37 | * and then destroy it. 38 | * 39 | */ 40 | 41 | #include "test.h" 42 | 43 | pthread_barrier_t barrier = NULL; 44 | 45 | int 46 | main() 47 | { 48 | assert(pthread_barrier_init(&barrier, NULL, 1) == 0); 49 | 50 | assert(pthread_barrier_wait(&barrier) == PTHREAD_BARRIER_SERIAL_THREAD); 51 | 52 | assert(pthread_barrier_destroy(&barrier) == 0); 53 | 54 | return 0; 55 | } 56 | -------------------------------------------------------------------------------- /third_party/pthread-w32/condvar.c: -------------------------------------------------------------------------------- 1 | /* 2 | * condvar.c 3 | * 4 | * Description: 5 | * This translation unit implements condition variables and their primitives. 6 | * 7 | * 8 | * -------------------------------------------------------------------------- 9 | * 10 | * Pthreads-win32 - POSIX Threads Library for Win32 11 | * Copyright(C) 1998 John E. Bossom 12 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 13 | * 14 | * Contact Email: rpj@callisto.canberra.edu.au 15 | * 16 | * The current list of contributors is contained 17 | * in the file CONTRIBUTORS included with the source 18 | * code distribution. The list can also be seen at the 19 | * following World Wide Web location: 20 | * http://sources.redhat.com/pthreads-win32/contributors.html 21 | * 22 | * This library is free software; you can redistribute it and/or 23 | * modify it under the terms of the GNU Lesser General Public 24 | * License as published by the Free Software Foundation; either 25 | * version 2 of the License, or (at your option) any later version. 26 | * 27 | * This library is distributed in the hope that it will be useful, 28 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 29 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 30 | * Lesser General Public License for more details. 31 | * 32 | * You should have received a copy of the GNU Lesser General Public 33 | * License along with this library in the file COPYING.LIB; 34 | * if not, write to the Free Software Foundation, Inc., 35 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 36 | * 37 | */ 38 | 39 | #include "pthread.h" 40 | #include "implement.h" 41 | 42 | #include "ptw32_cond_check_need_init.c" 43 | #include "pthread_condattr_init.c" 44 | #include "pthread_condattr_destroy.c" 45 | #include "pthread_condattr_getpshared.c" 46 | #include "pthread_condattr_setpshared.c" 47 | #include "pthread_cond_init.c" 48 | #include "pthread_cond_destroy.c" 49 | #include "pthread_cond_wait.c" 50 | #include "pthread_cond_signal.c" 51 | -------------------------------------------------------------------------------- /third_party/pthread-w32/ptw32_rwlock_cancelwrwait.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ptw32_rwlock_cancelwrwait.c 3 | * 4 | * Description: 5 | * This translation unit implements read/write lock primitives. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | 40 | void 41 | ptw32_rwlock_cancelwrwait (void *arg) 42 | { 43 | pthread_rwlock_t rwl = (pthread_rwlock_t) arg; 44 | 45 | rwl->nSharedAccessCount = -rwl->nCompletedSharedAccessCount; 46 | rwl->nCompletedSharedAccessCount = 0; 47 | 48 | (void) pthread_mutex_unlock (&(rwl->mtxSharedAccessCompleted)); 49 | (void) pthread_mutex_unlock (&(rwl->mtxExclusiveAccess)); 50 | } 51 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/exit2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Test for pthread_exit(). 3 | * 4 | * 5 | * -------------------------------------------------------------------------- 6 | * 7 | * Pthreads-win32 - POSIX Threads Library for Win32 8 | * Copyright(C) 1998 John E. Bossom 9 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 10 | * 11 | * Contact Email: rpj@callisto.canberra.edu.au 12 | * 13 | * The current list of contributors is contained 14 | * in the file CONTRIBUTORS included with the source 15 | * code distribution. The list can also be seen at the 16 | * following World Wide Web location: 17 | * http://sources.redhat.com/pthreads-win32/contributors.html 18 | * 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; either 22 | * version 2 of the License, or (at your option) any later version. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library in the file COPYING.LIB; 31 | * if not, write to the Free Software Foundation, Inc., 32 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33 | * 34 | * -------------------------------------------------------------------------- 35 | * 36 | * Depends on API functions: 37 | * pthread_create() 38 | * pthread_exit() 39 | */ 40 | 41 | #include "test.h" 42 | 43 | void * 44 | func(void * arg) 45 | { 46 | pthread_exit(arg); 47 | 48 | /* Never reached. */ 49 | assert(0); 50 | 51 | return NULL; 52 | } 53 | 54 | int 55 | main(int argc, char * argv[]) 56 | { 57 | pthread_t t; 58 | 59 | assert(pthread_create(&t, NULL, func, (void *) NULL) == 0); 60 | 61 | Sleep(100); 62 | 63 | return 0; 64 | } 65 | -------------------------------------------------------------------------------- /third_party/pthread-w32/pthread_attr_getscope.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pthread_attr_getscope.c 3 | * 4 | * Description: 5 | * This translation unit implements operations on thread attribute objects. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | 40 | /* ignore warning "unreferenced formal parameter" */ 41 | #if defined(_MSC_VER) 42 | #pragma warning( disable : 4100 ) 43 | #endif 44 | 45 | int 46 | pthread_attr_getscope (const pthread_attr_t * attr, int *contentionscope) 47 | { 48 | #if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) 49 | *contentionscope = (*attr)->contentionscope; 50 | return 0; 51 | #else 52 | return ENOSYS; 53 | #endif 54 | } 55 | -------------------------------------------------------------------------------- /third_party/pthread-w32/pthread_attr_setinheritsched.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pthread_attr_setinheritsched.c 3 | * 4 | * Description: 5 | * POSIX thread functions that deal with thread scheduling. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | #include "sched.h" 40 | 41 | int 42 | pthread_attr_setinheritsched (pthread_attr_t * attr, int inheritsched) 43 | { 44 | if (ptw32_is_attr (attr) != 0) 45 | { 46 | return EINVAL; 47 | } 48 | 49 | if (PTHREAD_INHERIT_SCHED != inheritsched 50 | && PTHREAD_EXPLICIT_SCHED != inheritsched) 51 | { 52 | return EINVAL; 53 | } 54 | 55 | (*attr)->inheritsched = inheritsched; 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/rwlock1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * rwlock1.c 3 | * 4 | * 5 | * -------------------------------------------------------------------------- 6 | * 7 | * Pthreads-win32 - POSIX Threads Library for Win32 8 | * Copyright(C) 1998 John E. Bossom 9 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 10 | * 11 | * Contact Email: rpj@callisto.canberra.edu.au 12 | * 13 | * The current list of contributors is contained 14 | * in the file CONTRIBUTORS included with the source 15 | * code distribution. The list can also be seen at the 16 | * following World Wide Web location: 17 | * http://sources.redhat.com/pthreads-win32/contributors.html 18 | * 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; either 22 | * version 2 of the License, or (at your option) any later version. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library in the file COPYING.LIB; 31 | * if not, write to the Free Software Foundation, Inc., 32 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33 | * 34 | * -------------------------------------------------------------------------- 35 | * 36 | * Create a simple rwlock object and then destroy it. 37 | * 38 | * Depends on API functions: 39 | * pthread_rwlock_init() 40 | * pthread_rwlock_destroy() 41 | */ 42 | 43 | #include "test.h" 44 | 45 | pthread_rwlock_t rwlock = NULL; 46 | 47 | int 48 | main() 49 | { 50 | assert(rwlock == NULL); 51 | 52 | assert(pthread_rwlock_init(&rwlock, NULL) == 0); 53 | 54 | assert(rwlock != NULL); 55 | 56 | assert(pthread_rwlock_destroy(&rwlock) == 0); 57 | 58 | assert(rwlock == NULL); 59 | 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/create1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * create1.c 3 | * 4 | * 5 | * -------------------------------------------------------------------------- 6 | * 7 | * Pthreads-win32 - POSIX Threads Library for Win32 8 | * Copyright(C) 1998 John E. Bossom 9 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 10 | * 11 | * Contact Email: rpj@callisto.canberra.edu.au 12 | * 13 | * The current list of contributors is contained 14 | * in the file CONTRIBUTORS included with the source 15 | * code distribution. The list can also be seen at the 16 | * following World Wide Web location: 17 | * http://sources.redhat.com/pthreads-win32/contributors.html 18 | * 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; either 22 | * version 2 of the License, or (at your option) any later version. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library in the file COPYING.LIB; 31 | * if not, write to the Free Software Foundation, Inc., 32 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33 | * 34 | * -------------------------------------------------------------------------- 35 | * 36 | * Description: 37 | * Create a thread and check that it ran. 38 | * 39 | * Depends on API functions: None. 40 | */ 41 | 42 | #include "test.h" 43 | 44 | static int washere = 0; 45 | 46 | void * func(void * arg) 47 | { 48 | washere = 1; 49 | return 0; 50 | } 51 | 52 | int 53 | main() 54 | { 55 | pthread_t t; 56 | 57 | assert(pthread_create(&t, NULL, func, NULL) == 0); 58 | 59 | /* A dirty hack, but we cannot rely on pthread_join in this 60 | primitive test. */ 61 | Sleep(2000); 62 | 63 | assert(washere == 1); 64 | 65 | return 0; 66 | } 67 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/spin1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * spin1.c 3 | * 4 | * 5 | * -------------------------------------------------------------------------- 6 | * 7 | * Pthreads-win32 - POSIX Threads Library for Win32 8 | * Copyright(C) 1998 John E. Bossom 9 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 10 | * 11 | * Contact Email: rpj@callisto.canberra.edu.au 12 | * 13 | * The current list of contributors is contained 14 | * in the file CONTRIBUTORS included with the source 15 | * code distribution. The list can also be seen at the 16 | * following World Wide Web location: 17 | * http://sources.redhat.com/pthreads-win32/contributors.html 18 | * 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; either 22 | * version 2 of the License, or (at your option) any later version. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library in the file COPYING.LIB; 31 | * if not, write to the Free Software Foundation, Inc., 32 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33 | * 34 | * -------------------------------------------------------------------------- 35 | * 36 | * Create a simple spinlock object, lock it, and then unlock it again. 37 | * This is the simplest test of the pthread mutex family that we can do. 38 | * 39 | */ 40 | 41 | #include "test.h" 42 | 43 | pthread_spinlock_t lock; 44 | 45 | int 46 | main() 47 | { 48 | assert(pthread_spin_init(&lock, PTHREAD_PROCESS_PRIVATE) == 0); 49 | 50 | assert(pthread_spin_lock(&lock) == 0); 51 | 52 | assert(pthread_spin_unlock(&lock) == 0); 53 | 54 | assert(pthread_spin_destroy(&lock) == 0); 55 | 56 | assert(pthread_spin_lock(&lock) == EINVAL); 57 | 58 | return 0; 59 | } 60 | -------------------------------------------------------------------------------- /third_party/zlib/uncompr.c: -------------------------------------------------------------------------------- 1 | /* uncompr.c -- decompress a memory buffer 2 | * Copyright (C) 1995-2003, 2010 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Decompresses the source buffer into the destination buffer. sourceLen is 13 | the byte length of the source buffer. Upon entry, destLen is the total 14 | size of the destination buffer, which must be large enough to hold the 15 | entire uncompressed data. (The size of the uncompressed data must have 16 | been saved previously by the compressor and transmitted to the decompressor 17 | by some mechanism outside the scope of this compression library.) 18 | Upon exit, destLen is the actual size of the compressed buffer. 19 | 20 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not 21 | enough memory, Z_BUF_ERROR if there was not enough room in the output 22 | buffer, or Z_DATA_ERROR if the input data was corrupted. 23 | */ 24 | int ZEXPORT uncompress (dest, destLen, source, sourceLen) 25 | Bytef *dest; 26 | uLongf *destLen; 27 | const Bytef *source; 28 | uLong sourceLen; 29 | { 30 | z_stream stream; 31 | int err; 32 | 33 | stream.next_in = (Bytef*)source; 34 | stream.avail_in = (uInt)sourceLen; 35 | /* Check for source > 64K on 16-bit machine: */ 36 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 37 | 38 | stream.next_out = dest; 39 | stream.avail_out = (uInt)*destLen; 40 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 41 | 42 | stream.zalloc = (alloc_func)0; 43 | stream.zfree = (free_func)0; 44 | 45 | err = inflateInit(&stream); 46 | if (err != Z_OK) return err; 47 | 48 | err = inflate(&stream, Z_FINISH); 49 | if (err != Z_STREAM_END) { 50 | inflateEnd(&stream); 51 | if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) 52 | return Z_DATA_ERROR; 53 | return err; 54 | } 55 | *destLen = stream.total_out; 56 | 57 | err = inflateEnd(&stream); 58 | return err; 59 | } 60 | -------------------------------------------------------------------------------- /third_party/pthread-w32/sem_close.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ------------------------------------------------------------- 3 | * 4 | * Module: sem_close.c 5 | * 6 | * Purpose: 7 | * Semaphores aren't actually part of the PThreads standard. 8 | * They are defined by the POSIX Standard: 9 | * 10 | * POSIX 1003.1b-1993 (POSIX.1b) 11 | * 12 | * ------------------------------------------------------------- 13 | * 14 | * -------------------------------------------------------------------------- 15 | * 16 | * Pthreads-win32 - POSIX Threads Library for Win32 17 | * Copyright(C) 1998 John E. Bossom 18 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 19 | * 20 | * Contact Email: rpj@callisto.canberra.edu.au 21 | * 22 | * The current list of contributors is contained 23 | * in the file CONTRIBUTORS included with the source 24 | * code distribution. The list can also be seen at the 25 | * following World Wide Web location: 26 | * http://sources.redhat.com/pthreads-win32/contributors.html 27 | * 28 | * This library is free software; you can redistribute it and/or 29 | * modify it under the terms of the GNU Lesser General Public 30 | * License as published by the Free Software Foundation; either 31 | * version 2 of the License, or (at your option) any later version. 32 | * 33 | * This library is distributed in the hope that it will be useful, 34 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 35 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 36 | * Lesser General Public License for more details. 37 | * 38 | * You should have received a copy of the GNU Lesser General Public 39 | * License along with this library in the file COPYING.LIB; 40 | * if not, write to the Free Software Foundation, Inc., 41 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 42 | */ 43 | 44 | #include "pthread.h" 45 | #include "semaphore.h" 46 | #include "implement.h" 47 | 48 | /* ignore warning "unreferenced formal parameter" */ 49 | #if defined(_MSC_VER) 50 | #pragma warning( disable : 4100 ) 51 | #endif 52 | 53 | int 54 | sem_close (sem_t * sem) 55 | { 56 | errno = ENOSYS; 57 | return -1; 58 | } /* sem_close */ 59 | -------------------------------------------------------------------------------- /third_party/pthread-w32/pthread_attr_getschedpolicy.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pthread_attr_getschedpolicy.c 3 | * 4 | * Description: 5 | * POSIX thread functions that deal with thread scheduling. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | #include "sched.h" 40 | 41 | int 42 | pthread_attr_getschedpolicy (const pthread_attr_t * attr, int *policy) 43 | { 44 | if (ptw32_is_attr (attr) != 0 || policy == NULL) 45 | { 46 | return EINVAL; 47 | } 48 | 49 | /* 50 | * Validate the policy arg. 51 | * Check that a policy constant wasn't passed rather than &policy. 52 | */ 53 | if (policy <= (int *) SCHED_MAX) 54 | { 55 | return EINVAL; 56 | } 57 | 58 | *policy = SCHED_OTHER; 59 | 60 | return 0; 61 | } 62 | -------------------------------------------------------------------------------- /third_party/pthread-w32/sem_unlink.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ------------------------------------------------------------- 3 | * 4 | * Module: sem_unlink.c 5 | * 6 | * Purpose: 7 | * Semaphores aren't actually part of the PThreads standard. 8 | * They are defined by the POSIX Standard: 9 | * 10 | * POSIX 1003.1b-1993 (POSIX.1b) 11 | * 12 | * ------------------------------------------------------------- 13 | * 14 | * -------------------------------------------------------------------------- 15 | * 16 | * Pthreads-win32 - POSIX Threads Library for Win32 17 | * Copyright(C) 1998 John E. Bossom 18 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 19 | * 20 | * Contact Email: rpj@callisto.canberra.edu.au 21 | * 22 | * The current list of contributors is contained 23 | * in the file CONTRIBUTORS included with the source 24 | * code distribution. The list can also be seen at the 25 | * following World Wide Web location: 26 | * http://sources.redhat.com/pthreads-win32/contributors.html 27 | * 28 | * This library is free software; you can redistribute it and/or 29 | * modify it under the terms of the GNU Lesser General Public 30 | * License as published by the Free Software Foundation; either 31 | * version 2 of the License, or (at your option) any later version. 32 | * 33 | * This library is distributed in the hope that it will be useful, 34 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 35 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 36 | * Lesser General Public License for more details. 37 | * 38 | * You should have received a copy of the GNU Lesser General Public 39 | * License along with this library in the file COPYING.LIB; 40 | * if not, write to the Free Software Foundation, Inc., 41 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 42 | */ 43 | 44 | #include "pthread.h" 45 | #include "semaphore.h" 46 | #include "implement.h" 47 | 48 | /* ignore warning "unreferenced formal parameter" */ 49 | #if defined(_MSC_VER) 50 | #pragma warning( disable : 4100 ) 51 | #endif 52 | 53 | int 54 | sem_unlink (const char *name) 55 | { 56 | errno = ENOSYS; 57 | return -1; 58 | } /* sem_unlink */ 59 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/exit3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Test for pthread_exit(). 3 | * 4 | * 5 | * -------------------------------------------------------------------------- 6 | * 7 | * Pthreads-win32 - POSIX Threads Library for Win32 8 | * Copyright(C) 1998 John E. Bossom 9 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 10 | * 11 | * Contact Email: rpj@callisto.canberra.edu.au 12 | * 13 | * The current list of contributors is contained 14 | * in the file CONTRIBUTORS included with the source 15 | * code distribution. The list can also be seen at the 16 | * following World Wide Web location: 17 | * http://sources.redhat.com/pthreads-win32/contributors.html 18 | * 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; either 22 | * version 2 of the License, or (at your option) any later version. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library in the file COPYING.LIB; 31 | * if not, write to the Free Software Foundation, Inc., 32 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33 | * 34 | * -------------------------------------------------------------------------- 35 | * 36 | * Depends on API functions: pthread_create(). 37 | */ 38 | 39 | #include "test.h" 40 | 41 | void * 42 | func(void * arg) 43 | { 44 | pthread_exit(arg); 45 | 46 | /* Never reached. */ 47 | assert(0); 48 | 49 | return NULL; 50 | } 51 | 52 | int 53 | main(int argc, char * argv[]) 54 | { 55 | pthread_t id[4]; 56 | int i; 57 | 58 | /* Create a few threads and then exit. */ 59 | for (i = 0; i < 4; i++) 60 | { 61 | assert(pthread_create(&id[i], NULL, func, (void *)(size_t)i) == 0); 62 | } 63 | 64 | Sleep(400); 65 | 66 | /* Success. */ 67 | return 0; 68 | } 69 | -------------------------------------------------------------------------------- /third_party/pthread-w32/sched.c: -------------------------------------------------------------------------------- 1 | /* 2 | * sched.c 3 | * 4 | * Description: 5 | * POSIX thread functions that deal with thread scheduling. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | #include "sched.h" 40 | 41 | #include "pthread_attr_setschedpolicy.c" 42 | #include "pthread_attr_getschedpolicy.c" 43 | #include "pthread_attr_setschedparam.c" 44 | #include "pthread_attr_getschedparam.c" 45 | #include "pthread_attr_setinheritsched.c" 46 | #include "pthread_attr_getinheritsched.c" 47 | #include "pthread_setschedparam.c" 48 | #include "pthread_getschedparam.c" 49 | #include "sched_get_priority_max.c" 50 | #include "sched_get_priority_min.c" 51 | #include "sched_setscheduler.c" 52 | #include "sched_getscheduler.c" 53 | #include "sched_yield.c" 54 | -------------------------------------------------------------------------------- /third_party/zlib/INDEX: -------------------------------------------------------------------------------- 1 | CMakeLists.txt cmake build file 2 | ChangeLog history of changes 3 | FAQ Frequently Asked Questions about zlib 4 | INDEX this file 5 | Makefile dummy Makefile that tells you to ./configure 6 | Makefile.in template for Unix Makefile 7 | README guess what 8 | configure configure script for Unix 9 | make_vms.com makefile for VMS 10 | test/example.c zlib usages examples for build testing 11 | test/minigzip.c minimal gzip-like functionality for build testing 12 | test/infcover.c inf*.c code coverage for build coverage testing 13 | treebuild.xml XML description of source file dependencies 14 | zconf.h.cmakein zconf.h template for cmake 15 | zconf.h.in zconf.h template for configure 16 | zlib.3 Man page for zlib 17 | zlib.3.pdf Man page in PDF format 18 | zlib.map Linux symbol information 19 | zlib.pc.in Template for pkg-config descriptor 20 | zlib.pc.cmakein zlib.pc template for cmake 21 | zlib2ansi perl script to convert source files for C++ compilation 22 | 23 | amiga/ makefiles for Amiga SAS C 24 | as400/ makefiles for AS/400 25 | doc/ documentation for formats and algorithms 26 | msdos/ makefiles for MSDOS 27 | nintendods/ makefile for Nintendo DS 28 | old/ makefiles for various architectures and zlib documentation 29 | files that have not yet been updated for zlib 1.2.x 30 | qnx/ makefiles for QNX 31 | watcom/ makefiles for OpenWatcom 32 | win32/ makefiles for Windows 33 | 34 | zlib public header files (required for library use): 35 | zconf.h 36 | zlib.h 37 | 38 | private source files used to build the zlib library: 39 | adler32.c 40 | compress.c 41 | crc32.c 42 | crc32.h 43 | deflate.c 44 | deflate.h 45 | gzclose.c 46 | gzguts.h 47 | gzlib.c 48 | gzread.c 49 | gzwrite.c 50 | infback.c 51 | inffast.c 52 | inffast.h 53 | inffixed.h 54 | inflate.c 55 | inflate.h 56 | inftrees.c 57 | inftrees.h 58 | trees.c 59 | trees.h 60 | uncompr.c 61 | zutil.c 62 | zutil.h 63 | 64 | source files for sample programs 65 | See examples/README.examples 66 | 67 | unsupported contributions by third parties 68 | See contrib/README.contrib 69 | -------------------------------------------------------------------------------- /third_party/pthread-w32/private.c: -------------------------------------------------------------------------------- 1 | /* 2 | * private.c 3 | * 4 | * Description: 5 | * This translation unit implements routines which are private to 6 | * the implementation and may be used throughout it. 7 | * 8 | * -------------------------------------------------------------------------- 9 | * 10 | * Pthreads-win32 - POSIX Threads Library for Win32 11 | * Copyright(C) 1998 John E. Bossom 12 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 13 | * 14 | * Contact Email: rpj@callisto.canberra.edu.au 15 | * 16 | * The current list of contributors is contained 17 | * in the file CONTRIBUTORS included with the source 18 | * code distribution. The list can also be seen at the 19 | * following World Wide Web location: 20 | * http://sources.redhat.com/pthreads-win32/contributors.html 21 | * 22 | * This library is free software; you can redistribute it and/or 23 | * modify it under the terms of the GNU Lesser General Public 24 | * License as published by the Free Software Foundation; either 25 | * version 2 of the License, or (at your option) any later version. 26 | * 27 | * This library is distributed in the hope that it will be useful, 28 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 29 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 30 | * Lesser General Public License for more details. 31 | * 32 | * You should have received a copy of the GNU Lesser General Public 33 | * License along with this library in the file COPYING.LIB; 34 | * if not, write to the Free Software Foundation, Inc., 35 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 36 | */ 37 | 38 | #include "pthread.h" 39 | #include "implement.h" 40 | 41 | #include "ptw32_MCS_lock.c" 42 | #include "ptw32_is_attr.c" 43 | #include "ptw32_processInitialize.c" 44 | #include "ptw32_processTerminate.c" 45 | #include "ptw32_threadStart.c" 46 | #include "ptw32_threadDestroy.c" 47 | #include "ptw32_tkAssocCreate.c" 48 | #include "ptw32_tkAssocDestroy.c" 49 | #include "ptw32_callUserDestroyRoutines.c" 50 | #include "ptw32_semwait.c" 51 | #include "ptw32_timespec.c" 52 | #include "ptw32_relmillisecs.c" 53 | #include "ptw32_throw.c" 54 | #include "ptw32_getprocessors.c" 55 | -------------------------------------------------------------------------------- /third_party/pthread-w32/attr.c: -------------------------------------------------------------------------------- 1 | /* 2 | * attr.c 3 | * 4 | * Description: 5 | * This translation unit agregates operations on thread attribute objects. 6 | * It is used for inline optimisation. 7 | * 8 | * The included modules are used separately when static executable sizes 9 | * must be minimised. 10 | * 11 | * -------------------------------------------------------------------------- 12 | * 13 | * Pthreads-win32 - POSIX Threads Library for Win32 14 | * Copyright(C) 1998 John E. Bossom 15 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 16 | * 17 | * Contact Email: rpj@callisto.canberra.edu.au 18 | * 19 | * The current list of contributors is contained 20 | * in the file CONTRIBUTORS included with the source 21 | * code distribution. The list can also be seen at the 22 | * following World Wide Web location: 23 | * http://sources.redhat.com/pthreads-win32/contributors.html 24 | * 25 | * This library is free software; you can redistribute it and/or 26 | * modify it under the terms of the GNU Lesser General Public 27 | * License as published by the Free Software Foundation; either 28 | * version 2 of the License, or (at your option) any later version. 29 | * 30 | * This library is distributed in the hope that it will be useful, 31 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 32 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 33 | * Lesser General Public License for more details. 34 | * 35 | * You should have received a copy of the GNU Lesser General Public 36 | * License along with this library in the file COPYING.LIB; 37 | * if not, write to the Free Software Foundation, Inc., 38 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 39 | */ 40 | 41 | #include "pthread.h" 42 | #include "implement.h" 43 | 44 | #include "pthread_attr_init.c" 45 | #include "pthread_attr_destroy.c" 46 | #include "pthread_attr_getdetachstate.c" 47 | #include "pthread_attr_setdetachstate.c" 48 | #include "pthread_attr_getstackaddr.c" 49 | #include "pthread_attr_setstackaddr.c" 50 | #include "pthread_attr_getstacksize.c" 51 | #include "pthread_attr_setstacksize.c" 52 | #include "pthread_attr_getscope.c" 53 | #include "pthread_attr_setscope.c" 54 | -------------------------------------------------------------------------------- /third_party/pthread-w32/sem_open.c: -------------------------------------------------------------------------------- 1 | /* 2 | * ------------------------------------------------------------- 3 | * 4 | * Module: sem_open.c 5 | * 6 | * Purpose: 7 | * Semaphores aren't actually part of the PThreads standard. 8 | * They are defined by the POSIX Standard: 9 | * 10 | * POSIX 1003.1b-1993 (POSIX.1b) 11 | * 12 | * ------------------------------------------------------------- 13 | * 14 | * -------------------------------------------------------------------------- 15 | * 16 | * Pthreads-win32 - POSIX Threads Library for Win32 17 | * Copyright(C) 1998 John E. Bossom 18 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 19 | * 20 | * Contact Email: rpj@callisto.canberra.edu.au 21 | * 22 | * The current list of contributors is contained 23 | * in the file CONTRIBUTORS included with the source 24 | * code distribution. The list can also be seen at the 25 | * following World Wide Web location: 26 | * http://sources.redhat.com/pthreads-win32/contributors.html 27 | * 28 | * This library is free software; you can redistribute it and/or 29 | * modify it under the terms of the GNU Lesser General Public 30 | * License as published by the Free Software Foundation; either 31 | * version 2 of the License, or (at your option) any later version. 32 | * 33 | * This library is distributed in the hope that it will be useful, 34 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 35 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 36 | * Lesser General Public License for more details. 37 | * 38 | * You should have received a copy of the GNU Lesser General Public 39 | * License along with this library in the file COPYING.LIB; 40 | * if not, write to the Free Software Foundation, Inc., 41 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 42 | */ 43 | 44 | #include "pthread.h" 45 | #include "semaphore.h" 46 | #include "implement.h" 47 | 48 | /* ignore warning "unreferenced formal parameter" */ 49 | #if defined(_MSC_VER) 50 | #pragma warning( disable : 4100 ) 51 | #endif 52 | 53 | int 54 | sem_open (const char *name, int oflag, mode_t mode, unsigned int value) 55 | { 56 | errno = ENOSYS; 57 | return -1; 58 | } /* sem_open */ 59 | -------------------------------------------------------------------------------- /third_party/pthread-w32/rwlock.c: -------------------------------------------------------------------------------- 1 | /* 2 | * rwlock.c 3 | * 4 | * Description: 5 | * This translation unit implements read/write lock primitives. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "ptw32_rwlock_check_need_init.c" 38 | #include "ptw32_rwlock_cancelwrwait.c" 39 | #include "pthread_rwlock_init.c" 40 | #include "pthread_rwlock_destroy.c" 41 | #include "pthread_rwlockattr_init.c" 42 | #include "pthread_rwlockattr_destroy.c" 43 | #include "pthread_rwlockattr_getpshared.c" 44 | #include "pthread_rwlockattr_setpshared.c" 45 | #include "pthread_rwlock_rdlock.c" 46 | #include "pthread_rwlock_timedrdlock.c" 47 | #include "pthread_rwlock_wrlock.c" 48 | #include "pthread_rwlock_timedwrlock.c" 49 | #include "pthread_rwlock_unlock.c" 50 | #include "pthread_rwlock_tryrdlock.c" 51 | #include "pthread_rwlock_trywrlock.c" 52 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/equal1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Test for pthread_equal. 3 | * 4 | * 5 | * -------------------------------------------------------------------------- 6 | * 7 | * Pthreads-win32 - POSIX Threads Library for Win32 8 | * Copyright(C) 1998 John E. Bossom 9 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 10 | * 11 | * Contact Email: rpj@callisto.canberra.edu.au 12 | * 13 | * The current list of contributors is contained 14 | * in the file CONTRIBUTORS included with the source 15 | * code distribution. The list can also be seen at the 16 | * following World Wide Web location: 17 | * http://sources.redhat.com/pthreads-win32/contributors.html 18 | * 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; either 22 | * version 2 of the License, or (at your option) any later version. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library in the file COPYING.LIB; 31 | * if not, write to the Free Software Foundation, Inc., 32 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33 | * 34 | * -------------------------------------------------------------------------- 35 | * 36 | * Depends on functions: pthread_create(). 37 | */ 38 | 39 | #include "test.h" 40 | 41 | void * func(void * arg) 42 | { 43 | Sleep(2000); 44 | return 0; 45 | } 46 | 47 | int 48 | main() 49 | { 50 | pthread_t t1, t2; 51 | 52 | assert(pthread_create(&t1, NULL, func, (void *) 1) == 0); 53 | 54 | assert(pthread_create(&t2, NULL, func, (void *) 2) == 0); 55 | 56 | assert(pthread_equal(t1, t2) == 0); 57 | 58 | assert(pthread_equal(t1,t1) != 0); 59 | 60 | /* This is a hack. We don't want to rely on pthread_join 61 | yet if we can help it. */ 62 | Sleep(4000); 63 | 64 | /* Success. */ 65 | return 0; 66 | } 67 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/self2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * self2.c 3 | * 4 | * 5 | * -------------------------------------------------------------------------- 6 | * 7 | * Pthreads-win32 - POSIX Threads Library for Win32 8 | * Copyright(C) 1998 John E. Bossom 9 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 10 | * 11 | * Contact Email: rpj@callisto.canberra.edu.au 12 | * 13 | * The current list of contributors is contained 14 | * in the file CONTRIBUTORS included with the source 15 | * code distribution. The list can also be seen at the 16 | * following World Wide Web location: 17 | * http://sources.redhat.com/pthreads-win32/contributors.html 18 | * 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; either 22 | * version 2 of the License, or (at your option) any later version. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library in the file COPYING.LIB; 31 | * if not, write to the Free Software Foundation, Inc., 32 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33 | * 34 | * -------------------------------------------------------------------------- 35 | * 36 | * Test for pthread_self(). 37 | * 38 | * Depends on API functions: 39 | * pthread_create() 40 | * pthread_self() 41 | * 42 | * Implicitly depends on: 43 | * pthread_getspecific() 44 | * pthread_setspecific() 45 | */ 46 | 47 | #include "test.h" 48 | #include 49 | 50 | static pthread_t me; 51 | 52 | void * 53 | entry(void * arg) 54 | { 55 | me = pthread_self(); 56 | 57 | return arg; 58 | } 59 | 60 | int 61 | main() 62 | { 63 | pthread_t t; 64 | 65 | assert(pthread_create(&t, NULL, entry, NULL) == 0); 66 | 67 | Sleep(100); 68 | 69 | assert(pthread_equal(t, me) != 0); 70 | 71 | /* Success. */ 72 | return 0; 73 | } 74 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/join0.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Test for pthread_join(). 3 | * 4 | * 5 | * -------------------------------------------------------------------------- 6 | * 7 | * Pthreads-win32 - POSIX Threads Library for Win32 8 | * Copyright(C) 1998 John E. Bossom 9 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 10 | * 11 | * Contact Email: rpj@callisto.canberra.edu.au 12 | * 13 | * The current list of contributors is contained 14 | * in the file CONTRIBUTORS included with the source 15 | * code distribution. The list can also be seen at the 16 | * following World Wide Web location: 17 | * http://sources.redhat.com/pthreads-win32/contributors.html 18 | * 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; either 22 | * version 2 of the License, or (at your option) any later version. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library in the file COPYING.LIB; 31 | * if not, write to the Free Software Foundation, Inc., 32 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33 | * 34 | * -------------------------------------------------------------------------- 35 | * 36 | * Depends on API functions: pthread_create(), pthread_exit(). 37 | */ 38 | 39 | #include "test.h" 40 | 41 | void * 42 | func(void * arg) 43 | { 44 | Sleep(2000); 45 | 46 | pthread_exit(arg); 47 | 48 | /* Never reached. */ 49 | exit(1); 50 | } 51 | 52 | int 53 | main(int argc, char * argv[]) 54 | { 55 | pthread_t id; 56 | void* result = (void*)0; 57 | 58 | /* Create a single thread and wait for it to exit. */ 59 | assert(pthread_create(&id, NULL, func, (void *) 123) == 0); 60 | 61 | assert(pthread_join(id, &result) == 0); 62 | 63 | assert((int)(size_t)result == 123); 64 | 65 | /* Success. */ 66 | return 0; 67 | } 68 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/mutex2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * mutex2.c 3 | * 4 | * 5 | * -------------------------------------------------------------------------- 6 | * 7 | * Pthreads-win32 - POSIX Threads Library for Win32 8 | * Copyright(C) 1998 John E. Bossom 9 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 10 | * 11 | * Contact Email: rpj@callisto.canberra.edu.au 12 | * 13 | * The current list of contributors is contained 14 | * in the file CONTRIBUTORS included with the source 15 | * code distribution. The list can also be seen at the 16 | * following World Wide Web location: 17 | * http://sources.redhat.com/pthreads-win32/contributors.html 18 | * 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; either 22 | * version 2 of the License, or (at your option) any later version. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library in the file COPYING.LIB; 31 | * if not, write to the Free Software Foundation, Inc., 32 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33 | * 34 | * -------------------------------------------------------------------------- 35 | * 36 | * Declare a static mutex object, lock it, 37 | * and then unlock it again. 38 | * 39 | * Depends on API functions: 40 | * pthread_mutex_lock() 41 | * pthread_mutex_unlock() 42 | */ 43 | 44 | #include "test.h" 45 | 46 | pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; 47 | 48 | int 49 | main() 50 | { 51 | assert(mutex == PTHREAD_MUTEX_INITIALIZER); 52 | 53 | assert(pthread_mutex_lock(&mutex) == 0); 54 | 55 | assert(mutex != PTHREAD_MUTEX_INITIALIZER); 56 | 57 | assert(mutex != NULL); 58 | 59 | assert(pthread_mutex_unlock(&mutex) == 0); 60 | 61 | assert(pthread_mutex_destroy(&mutex) == 0); 62 | 63 | assert(mutex == NULL); 64 | 65 | return 0; 66 | } 67 | -------------------------------------------------------------------------------- /third_party/pthread-w32/pthread_attr_setscope.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pthread_attr_setscope.c 3 | * 4 | * Description: 5 | * This translation unit implements operations on thread attribute objects. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | 40 | /* ignore warning "unreferenced formal parameter" */ 41 | #if defined(_MSC_VER) 42 | #pragma warning( disable : 4100 ) 43 | #endif 44 | 45 | int 46 | pthread_attr_setscope (pthread_attr_t * attr, int contentionscope) 47 | { 48 | #if defined(_POSIX_THREAD_PRIORITY_SCHEDULING) 49 | switch (contentionscope) 50 | { 51 | case PTHREAD_SCOPE_SYSTEM: 52 | (*attr)->contentionscope = contentionscope; 53 | return 0; 54 | case PTHREAD_SCOPE_PROCESS: 55 | return ENOTSUP; 56 | default: 57 | return EINVAL; 58 | } 59 | #else 60 | return ENOSYS; 61 | #endif 62 | } 63 | -------------------------------------------------------------------------------- /third_party/pthread-w32/pthread_attr_setschedparam.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pthread_attr_setschedparam.c 3 | * 4 | * Description: 5 | * POSIX thread functions that deal with thread scheduling. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | #include "sched.h" 40 | 41 | int 42 | pthread_attr_setschedparam (pthread_attr_t * attr, 43 | const struct sched_param *param) 44 | { 45 | int priority; 46 | 47 | if (ptw32_is_attr (attr) != 0 || param == NULL) 48 | { 49 | return EINVAL; 50 | } 51 | 52 | priority = param->sched_priority; 53 | 54 | /* Validate priority level. */ 55 | if (priority < sched_get_priority_min (SCHED_OTHER) || 56 | priority > sched_get_priority_max (SCHED_OTHER)) 57 | { 58 | return EINVAL; 59 | } 60 | 61 | memcpy (&(*attr)->param, param, sizeof (*param)); 62 | return 0; 63 | } 64 | -------------------------------------------------------------------------------- /third_party/pthread-w32/manual/pthread_exit.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | PTHREAD_EXIT(3) manual page 7 | 8 | 9 | Table of Contents

10 | 11 |

12 |

Name

13 | pthread_exit - terminate the calling thread 14 |

15 |

Synopsis

16 | #include <pthread.h> 17 | 18 |

void pthread_exit(void *retval); 19 |

20 |

Description

21 | pthread_exit terminates the 22 | execution of the calling thread. All cleanup handlers that have been set 23 | for the calling thread with pthread_cleanup_push(3) 24 | are executed in reverse 25 | order (the most recently pushed handler is executed first). Finalization 26 | functions for thread-specific data are then called for all keys that have 27 | non- NULL values associated with them in the calling thread (see pthread_key_create(3) 28 | ). 29 | Finally, execution of the calling thread is stopped. 30 |

The retval argument 31 | is the return value of the thread. It can be consulted from another thread 32 | using pthread_join(3) 33 | . 34 |

35 |

Return Value

36 | The pthread_exit function never returns. 37 | 38 |

39 |

Author

40 | Xavier Leroy <Xavier.Leroy@inria.fr> 41 |

42 |

See Also

43 | pthread_create(3) 44 | , pthread_join(3) 45 | . 46 |

47 | 48 |


49 | Table of Contents

50 |

58 | 59 | 60 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/rwlock2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * rwlock2.c 3 | * 4 | * 5 | * -------------------------------------------------------------------------- 6 | * 7 | * Pthreads-win32 - POSIX Threads Library for Win32 8 | * Copyright(C) 1998 John E. Bossom 9 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 10 | * 11 | * Contact Email: rpj@callisto.canberra.edu.au 12 | * 13 | * The current list of contributors is contained 14 | * in the file CONTRIBUTORS included with the source 15 | * code distribution. The list can also be seen at the 16 | * following World Wide Web location: 17 | * http://sources.redhat.com/pthreads-win32/contributors.html 18 | * 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; either 22 | * version 2 of the License, or (at your option) any later version. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library in the file COPYING.LIB; 31 | * if not, write to the Free Software Foundation, Inc., 32 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33 | * 34 | * -------------------------------------------------------------------------- 35 | * 36 | * Declare a static rwlock object, lock it, 37 | * and then unlock it again. 38 | * 39 | * Depends on API functions: 40 | * pthread_rwlock_rdlock() 41 | * pthread_rwlock_unlock() 42 | */ 43 | 44 | #include "test.h" 45 | 46 | pthread_rwlock_t rwlock = PTHREAD_RWLOCK_INITIALIZER; 47 | 48 | int 49 | main() 50 | { 51 | assert(rwlock == PTHREAD_RWLOCK_INITIALIZER); 52 | 53 | assert(pthread_rwlock_rdlock(&rwlock) == 0); 54 | 55 | assert(rwlock != PTHREAD_RWLOCK_INITIALIZER); 56 | 57 | assert(rwlock != NULL); 58 | 59 | assert(pthread_rwlock_unlock(&rwlock) == 0); 60 | 61 | assert(pthread_rwlock_destroy(&rwlock) == 0); 62 | 63 | assert(rwlock == NULL); 64 | 65 | return 0; 66 | } 67 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/mutex2r.c: -------------------------------------------------------------------------------- 1 | /* 2 | * mutex2r.c 3 | * 4 | * 5 | * -------------------------------------------------------------------------- 6 | * 7 | * Pthreads-win32 - POSIX Threads Library for Win32 8 | * Copyright(C) 1998 John E. Bossom 9 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 10 | * 11 | * Contact Email: rpj@callisto.canberra.edu.au 12 | * 13 | * The current list of contributors is contained 14 | * in the file CONTRIBUTORS included with the source 15 | * code distribution. The list can also be seen at the 16 | * following World Wide Web location: 17 | * http://sources.redhat.com/pthreads-win32/contributors.html 18 | * 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; either 22 | * version 2 of the License, or (at your option) any later version. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library in the file COPYING.LIB; 31 | * if not, write to the Free Software Foundation, Inc., 32 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33 | * 34 | * -------------------------------------------------------------------------- 35 | * 36 | * Declare a static mutex object, lock it, 37 | * and then unlock it again. 38 | * 39 | * Depends on API functions: 40 | * pthread_mutex_lock() 41 | * pthread_mutex_unlock() 42 | */ 43 | 44 | #include "test.h" 45 | 46 | pthread_mutex_t mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER; 47 | 48 | int 49 | main() 50 | { 51 | assert(mutex == PTHREAD_RECURSIVE_MUTEX_INITIALIZER); 52 | 53 | assert(pthread_mutex_lock(&mutex) == 0); 54 | 55 | assert(mutex != PTHREAD_RECURSIVE_MUTEX_INITIALIZER); 56 | 57 | assert(mutex != NULL); 58 | 59 | assert(pthread_mutex_unlock(&mutex) == 0); 60 | 61 | assert(pthread_mutex_destroy(&mutex) == 0); 62 | 63 | assert(mutex == NULL); 64 | 65 | return 0; 66 | } 67 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/mutex2e.c: -------------------------------------------------------------------------------- 1 | /* 2 | * mutex2e.c 3 | * 4 | * 5 | * -------------------------------------------------------------------------- 6 | * 7 | * Pthreads-win32 - POSIX Threads Library for Win32 8 | * Copyright(C) 1998 John E. Bossom 9 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 10 | * 11 | * Contact Email: rpj@callisto.canberra.edu.au 12 | * 13 | * The current list of contributors is contained 14 | * in the file CONTRIBUTORS included with the source 15 | * code distribution. The list can also be seen at the 16 | * following World Wide Web location: 17 | * http://sources.redhat.com/pthreads-win32/contributors.html 18 | * 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; either 22 | * version 2 of the License, or (at your option) any later version. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library in the file COPYING.LIB; 31 | * if not, write to the Free Software Foundation, Inc., 32 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33 | * 34 | * -------------------------------------------------------------------------- 35 | * 36 | * Declare a static mutex object, lock it, 37 | * and then unlock it again. 38 | * 39 | * Depends on API functions: 40 | * pthread_mutex_lock() 41 | * pthread_mutex_unlock() 42 | */ 43 | 44 | #include "test.h" 45 | 46 | pthread_mutex_t mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER; 47 | 48 | int 49 | main() 50 | { 51 | assert(mutex == PTHREAD_ERRORCHECK_MUTEX_INITIALIZER); 52 | 53 | assert(pthread_mutex_lock(&mutex) == 0); 54 | 55 | assert(mutex != PTHREAD_ERRORCHECK_MUTEX_INITIALIZER); 56 | 57 | assert(mutex != NULL); 58 | 59 | assert(pthread_mutex_unlock(&mutex) == 0); 60 | 61 | assert(pthread_mutex_destroy(&mutex) == 0); 62 | 63 | assert(mutex == NULL); 64 | 65 | return 0; 66 | } 67 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/join2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Test for pthread_join() returning return value from threads. 3 | * 4 | * 5 | * -------------------------------------------------------------------------- 6 | * 7 | * Pthreads-win32 - POSIX Threads Library for Win32 8 | * Copyright(C) 1998 John E. Bossom 9 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 10 | * 11 | * Contact Email: rpj@callisto.canberra.edu.au 12 | * 13 | * The current list of contributors is contained 14 | * in the file CONTRIBUTORS included with the source 15 | * code distribution. The list can also be seen at the 16 | * following World Wide Web location: 17 | * http://sources.redhat.com/pthreads-win32/contributors.html 18 | * 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; either 22 | * version 2 of the License, or (at your option) any later version. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library in the file COPYING.LIB; 31 | * if not, write to the Free Software Foundation, Inc., 32 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33 | * 34 | * -------------------------------------------------------------------------- 35 | * 36 | * Depends on API functions: pthread_create(). 37 | */ 38 | 39 | #include "test.h" 40 | 41 | void * 42 | func(void * arg) 43 | { 44 | Sleep(1000); 45 | return arg; 46 | } 47 | 48 | int 49 | main(int argc, char * argv[]) 50 | { 51 | pthread_t id[4]; 52 | int i; 53 | void* result = (void*)-1; 54 | 55 | /* Create a few threads and then exit. */ 56 | for (i = 0; i < 4; i++) 57 | { 58 | assert(pthread_create(&id[i], NULL, func, (void *)(size_t)i) == 0); 59 | } 60 | 61 | for (i = 0; i < 4; i++) 62 | { 63 | assert(pthread_join(id[i], &result) == 0); 64 | assert((int)(size_t)result == i); 65 | } 66 | 67 | /* Success. */ 68 | return 0; 69 | } 70 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/README.BENCHTESTS: -------------------------------------------------------------------------------- 1 | 2 | ------------ 3 | Benchmarking 4 | ------------ 5 | There is a set a benchmarking programs in the 6 | "tests" directory. These should be runnable using the 7 | following command-lines corresponding to each of the possible 8 | library builds: 9 | 10 | MSVC: 11 | nmake clean VC-bench 12 | nmake clean VCE-bench 13 | nmake clean VSE-bench 14 | 15 | Mingw32: 16 | make clean GC-bench 17 | make clean GCE-bench 18 | 19 | UWIN: 20 | The benchtests are run as part of the testsuite. 21 | 22 | 23 | Mutex benchtests 24 | ---------------- 25 | 26 | benchtest1 - Lock plus unlock on an unlocked mutex. 27 | benchtest2 - Lock plus unlock on a locked mutex. 28 | benchtest3 - Trylock on a locked mutex. 29 | benchtest4 - Trylock plus unlock on an unlocked mutex. 30 | 31 | 32 | Each test times up to three alternate synchronisation 33 | implementations as a reference, and then times each of 34 | the four mutex types provided by the library. Each is 35 | described below: 36 | 37 | Simple Critical Section 38 | - uses a simple Win32 critical section. There is no 39 | additional overhead for this case as there is in the 40 | remaining cases. 41 | 42 | POSIX mutex implemented using a Critical Section 43 | - The old implementation which uses runtime adaptation 44 | depending on the Windows variant being run on. When 45 | the pthreads DLL was run on WinNT or higher then 46 | POSIX mutexes would use Win32 Critical Sections. 47 | 48 | POSIX mutex implemented using a Win32 Mutex 49 | - The old implementation which uses runtime adaptation 50 | depending on the Windows variant being run on. When 51 | the pthreads DLL was run on Win9x then POSIX mutexes 52 | would use Win32 Mutexes (because TryEnterCriticalSection 53 | is not implemented on Win9x). 54 | 55 | PTHREAD_MUTEX_DEFAULT 56 | PTHREAD_MUTEX_NORMAL 57 | PTHREAD_MUTEX_ERRORCHECK 58 | PTHREAD_MUTEX_RECURSIVE 59 | - The current implementation supports these mutex types. 60 | The underlying basis of POSIX mutexes is now the same 61 | irrespective of the Windows variant, and should therefore 62 | have consistent performance. 63 | 64 | 65 | Semaphore benchtests 66 | -------------------- 67 | 68 | benchtest5 - Timing for various uncontended cases. 69 | 70 | 71 | In all benchtests, the operation is repeated a large 72 | number of times and an average is calculated. Loop 73 | overhead is measured and subtracted from all test times. 74 | 75 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/once1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * once1.c 3 | * 4 | * 5 | * -------------------------------------------------------------------------- 6 | * 7 | * Pthreads-win32 - POSIX Threads Library for Win32 8 | * Copyright(C) 1998 John E. Bossom 9 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 10 | * 11 | * Contact Email: rpj@callisto.canberra.edu.au 12 | * 13 | * The current list of contributors is contained 14 | * in the file CONTRIBUTORS included with the source 15 | * code distribution. The list can also be seen at the 16 | * following World Wide Web location: 17 | * http://sources.redhat.com/pthreads-win32/contributors.html 18 | * 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; either 22 | * version 2 of the License, or (at your option) any later version. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library in the file COPYING.LIB; 31 | * if not, write to the Free Software Foundation, Inc., 32 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33 | * 34 | * -------------------------------------------------------------------------- 35 | * 36 | * Create a static pthread_once and test that it calls myfunc once. 37 | * 38 | * Depends on API functions: 39 | * pthread_once() 40 | * pthread_create() 41 | */ 42 | 43 | #include "test.h" 44 | 45 | pthread_once_t once = PTHREAD_ONCE_INIT; 46 | 47 | static int washere = 0; 48 | 49 | void 50 | myfunc(void) 51 | { 52 | washere++; 53 | } 54 | 55 | void * 56 | mythread(void * arg) 57 | { 58 | assert(pthread_once(&once, myfunc) == 0); 59 | 60 | return 0; 61 | } 62 | 63 | int 64 | main() 65 | { 66 | pthread_t t1, t2; 67 | 68 | assert(pthread_create(&t1, NULL, mythread, NULL) == 0); 69 | 70 | assert(pthread_create(&t2, NULL, mythread, NULL) == 0); 71 | 72 | Sleep(2000); 73 | 74 | assert(washere == 1); 75 | 76 | return 0; 77 | } 78 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/mutex1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * mutex1.c 3 | * 4 | * 5 | * -------------------------------------------------------------------------- 6 | * 7 | * Pthreads-win32 - POSIX Threads Library for Win32 8 | * Copyright(C) 1998 John E. Bossom 9 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 10 | * 11 | * Contact Email: rpj@callisto.canberra.edu.au 12 | * 13 | * The current list of contributors is contained 14 | * in the file CONTRIBUTORS included with the source 15 | * code distribution. The list can also be seen at the 16 | * following World Wide Web location: 17 | * http://sources.redhat.com/pthreads-win32/contributors.html 18 | * 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; either 22 | * version 2 of the License, or (at your option) any later version. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library in the file COPYING.LIB; 31 | * if not, write to the Free Software Foundation, Inc., 32 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33 | * 34 | * -------------------------------------------------------------------------- 35 | * 36 | * Create a simple mutex object, lock it, and then unlock it again. 37 | * This is the simplest test of the pthread mutex family that we can do. 38 | * 39 | * Depends on API functions: 40 | * pthread_mutex_init() 41 | * pthread_mutex_lock() 42 | * pthread_mutex_unlock() 43 | * pthread_mutex_destroy() 44 | */ 45 | 46 | #include "test.h" 47 | 48 | pthread_mutex_t mutex = NULL; 49 | 50 | int 51 | main() 52 | { 53 | assert(mutex == NULL); 54 | 55 | assert(pthread_mutex_init(&mutex, NULL) == 0); 56 | 57 | assert(mutex != NULL); 58 | 59 | assert(pthread_mutex_lock(&mutex) == 0); 60 | 61 | assert(pthread_mutex_unlock(&mutex) == 0); 62 | 63 | assert(pthread_mutex_destroy(&mutex) == 0); 64 | 65 | assert(mutex == NULL); 66 | 67 | return 0; 68 | } 69 | -------------------------------------------------------------------------------- /third_party/pthread-w32/pthread_getw32threadhandle_np.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pthread_getw32threadhandle_np.c 3 | * 4 | * Description: 5 | * This translation unit implements non-portable thread functions. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | 40 | /* 41 | * pthread_getw32threadhandle_np() 42 | * 43 | * Returns the win32 thread handle that the POSIX 44 | * thread "thread" is running as. 45 | * 46 | * Applications can use the win32 handle to set 47 | * win32 specific attributes of the thread. 48 | */ 49 | HANDLE 50 | pthread_getw32threadhandle_np (pthread_t thread) 51 | { 52 | return ((ptw32_thread_t *)thread.p)->threadH; 53 | } 54 | 55 | /* 56 | * pthread_getw32threadid_np() 57 | * 58 | * Returns the win32 thread id that the POSIX 59 | * thread "thread" is running as. 60 | */ 61 | DWORD 62 | pthread_getw32threadid_np (pthread_t thread) 63 | { 64 | return ((ptw32_thread_t *)thread.p)->thread; 65 | } 66 | -------------------------------------------------------------------------------- /third_party/pthread-w32/pthread.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pthread.c 3 | * 4 | * Description: 5 | * This translation unit agregates pthreads-win32 translation units. 6 | * It is used for inline optimisation of the library, 7 | * maximising for speed at the expense of size. 8 | * 9 | * -------------------------------------------------------------------------- 10 | * 11 | * Pthreads-win32 - POSIX Threads Library for Win32 12 | * Copyright(C) 1998 John E. Bossom 13 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 14 | * 15 | * Contact Email: rpj@callisto.canberra.edu.au 16 | * 17 | * The current list of contributors is contained 18 | * in the file CONTRIBUTORS included with the source 19 | * code distribution. The list can also be seen at the 20 | * following World Wide Web location: 21 | * http://sources.redhat.com/pthreads-win32/contributors.html 22 | * 23 | * This library is free software; you can redistribute it and/or 24 | * modify it under the terms of the GNU Lesser General Public 25 | * License as published by the Free Software Foundation; either 26 | * version 2 of the License, or (at your option) any later version. 27 | * 28 | * This library is distributed in the hope that it will be useful, 29 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 30 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 31 | * Lesser General Public License for more details. 32 | * 33 | * You should have received a copy of the GNU Lesser General Public 34 | * License along with this library in the file COPYING.LIB; 35 | * if not, write to the Free Software Foundation, Inc., 36 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 37 | */ 38 | 39 | #include "pthread.h" 40 | #include "implement.h" 41 | 42 | /* The following are ordered for inlining */ 43 | 44 | #include "private.c" 45 | #include "attr.c" 46 | #include "barrier.c" 47 | #include "cancel.c" 48 | #include "cleanup.c" 49 | #include "condvar.c" 50 | #include "create.c" 51 | #include "dll.c" 52 | #include "autostatic.c" 53 | #include "errno.c" 54 | #include "exit.c" 55 | #include "fork.c" 56 | #include "global.c" 57 | #include "misc.c" 58 | #include "mutex.c" 59 | #include "nonportable.c" 60 | #include "rwlock.c" 61 | #include "sched.c" 62 | #include "semaphore.c" 63 | #include "signal.c" 64 | #include "spin.c" 65 | #include "sync.c" 66 | #include "tsd.c" 67 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/self1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * self1.c 3 | * 4 | * 5 | * -------------------------------------------------------------------------- 6 | * 7 | * Pthreads-win32 - POSIX Threads Library for Win32 8 | * Copyright(C) 1998 John E. Bossom 9 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 10 | * 11 | * Contact Email: rpj@callisto.canberra.edu.au 12 | * 13 | * The current list of contributors is contained 14 | * in the file CONTRIBUTORS included with the source 15 | * code distribution. The list can also be seen at the 16 | * following World Wide Web location: 17 | * http://sources.redhat.com/pthreads-win32/contributors.html 18 | * 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; either 22 | * version 2 of the License, or (at your option) any later version. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library in the file COPYING.LIB; 31 | * if not, write to the Free Software Foundation, Inc., 32 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33 | * 34 | * -------------------------------------------------------------------------- 35 | * 36 | * Test for pthread_self(). 37 | * 38 | * Depends on API functions: 39 | * pthread_self() 40 | * 41 | * Implicitly depends on: 42 | * pthread_getspecific() 43 | * pthread_setspecific() 44 | */ 45 | 46 | #include "test.h" 47 | 48 | int 49 | main(int argc, char * argv[]) 50 | { 51 | /* 52 | * This should always succeed unless the system has no 53 | * resources (memory) left. 54 | */ 55 | pthread_t self; 56 | 57 | #if defined(PTW32_STATIC_LIB) && !(defined(_MSC_VER) || defined(__MINGW32__)) 58 | pthread_win32_process_attach_np(); 59 | #endif 60 | 61 | self = pthread_self(); 62 | 63 | assert(self.p != NULL); 64 | 65 | #if defined(PTW32_STATIC_LIB) && !(defined(_MSC_VER) || defined(__MINGW32__)) 66 | pthread_win32_process_detach_np(); 67 | #endif 68 | return 0; 69 | } 70 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/mutex8.c: -------------------------------------------------------------------------------- 1 | /* 2 | * mutex8.c 3 | * 4 | * 5 | * Pthreads-win32 - POSIX Threads Library for Win32 6 | * Copyright (C) 1998 Ben Elliston and Ross Johnson 7 | * Copyright (C) 1999,2000,2001 Ross Johnson 8 | * 9 | * Contact Email: rpj@ise.canberra.edu.au 10 | * 11 | * This library is free software; you can redistribute it and/or 12 | * modify it under the terms of the GNU Lesser General Public 13 | * License as published by the Free Software Foundation; either 14 | * version 2.1 of the License, or (at your option) any later version. 15 | * 16 | * This library is distributed in the hope that it will be useful, 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 19 | * Lesser General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU Lesser General Public 22 | * License along with this library; if not, write to the Free Software 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 | * 25 | * -------------------------------------------------------------------------- 26 | * 27 | * Test the default (type not set) mutex type exercising timedlock. 28 | * Thread locks mutex, another thread timedlocks the mutex. 29 | * Timed thread should timeout. 30 | * 31 | * Depends on API functions: 32 | * pthread_mutex_lock() 33 | * pthread_mutex_timedlock() 34 | * pthread_mutex_unlock() 35 | */ 36 | 37 | #include "test.h" 38 | #include 39 | 40 | static int lockCount = 0; 41 | 42 | static pthread_mutex_t mutex; 43 | 44 | void * locker(void * arg) 45 | { 46 | struct timespec abstime = { 0, 0 }; 47 | PTW32_STRUCT_TIMEB currSysTime; 48 | const DWORD NANOSEC_PER_MILLISEC = 1000000; 49 | 50 | PTW32_FTIME(&currSysTime); 51 | 52 | abstime.tv_sec = (long)currSysTime.time; 53 | abstime.tv_nsec = NANOSEC_PER_MILLISEC * currSysTime.millitm; 54 | 55 | abstime.tv_sec += 1; 56 | 57 | assert(pthread_mutex_timedlock(&mutex, &abstime) == ETIMEDOUT); 58 | 59 | lockCount++; 60 | 61 | return 0; 62 | } 63 | 64 | int 65 | main() 66 | { 67 | pthread_t t; 68 | 69 | assert(pthread_mutex_init(&mutex, NULL) == 0); 70 | 71 | assert(pthread_mutex_lock(&mutex) == 0); 72 | 73 | assert(pthread_create(&t, NULL, locker, NULL) == 0); 74 | 75 | Sleep(2000); 76 | 77 | assert(lockCount == 1); 78 | 79 | assert(pthread_mutex_unlock(&mutex) == 0); 80 | 81 | return 0; 82 | } 83 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/spin2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * spin2.c 3 | * 4 | * 5 | * -------------------------------------------------------------------------- 6 | * 7 | * Pthreads-win32 - POSIX Threads Library for Win32 8 | * Copyright(C) 1998 John E. Bossom 9 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 10 | * 11 | * Contact Email: rpj@callisto.canberra.edu.au 12 | * 13 | * The current list of contributors is contained 14 | * in the file CONTRIBUTORS included with the source 15 | * code distribution. The list can also be seen at the 16 | * following World Wide Web location: 17 | * http://sources.redhat.com/pthreads-win32/contributors.html 18 | * 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; either 22 | * version 2 of the License, or (at your option) any later version. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library in the file COPYING.LIB; 31 | * if not, write to the Free Software Foundation, Inc., 32 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33 | * 34 | * -------------------------------------------------------------------------- 35 | * 36 | * Declare a spinlock object, lock it, trylock it, 37 | * and then unlock it again. 38 | * 39 | */ 40 | 41 | #include "test.h" 42 | 43 | pthread_spinlock_t lock = NULL; 44 | 45 | static int washere = 0; 46 | 47 | void * func(void * arg) 48 | { 49 | assert(pthread_spin_trylock(&lock) == EBUSY); 50 | 51 | washere = 1; 52 | 53 | return 0; 54 | } 55 | 56 | int 57 | main() 58 | { 59 | pthread_t t; 60 | 61 | assert(pthread_spin_init(&lock, PTHREAD_PROCESS_PRIVATE) == 0); 62 | 63 | assert(pthread_spin_lock(&lock) == 0); 64 | 65 | assert(pthread_create(&t, NULL, func, NULL) == 0); 66 | assert(pthread_join(t, NULL) == 0); 67 | 68 | assert(pthread_spin_unlock(&lock) == 0); 69 | 70 | assert(pthread_spin_destroy(&lock) == 0); 71 | 72 | assert(washere == 1); 73 | 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /third_party/pthread-w32/sched_getscheduler.c: -------------------------------------------------------------------------------- 1 | /* 2 | * sched_getscheduler.c 3 | * 4 | * Description: 5 | * POSIX thread functions that deal with thread scheduling. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | #include "sched.h" 40 | 41 | int 42 | sched_getscheduler (pid_t pid) 43 | { 44 | /* 45 | * Win32 only has one policy which we call SCHED_OTHER. 46 | * However, we try to provide other valid side-effects 47 | * such as EPERM and ESRCH errors. 48 | */ 49 | if (0 != pid) 50 | { 51 | int selfPid = (int) GetCurrentProcessId (); 52 | 53 | if (pid != selfPid) 54 | { 55 | HANDLE h = 56 | OpenProcess (PROCESS_QUERY_INFORMATION, PTW32_FALSE, (DWORD) pid); 57 | 58 | if (NULL == h) 59 | { 60 | errno = 61 | (GetLastError () == 62 | (0xFF & ERROR_ACCESS_DENIED)) ? EPERM : ESRCH; 63 | return -1; 64 | } 65 | else 66 | CloseHandle(h); 67 | } 68 | } 69 | 70 | return SCHED_OTHER; 71 | } 72 | -------------------------------------------------------------------------------- /third_party/jpeg/jcinit.c: -------------------------------------------------------------------------------- 1 | /* 2 | * jcinit.c 3 | * 4 | * Copyright (C) 1991-1997, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains initialization logic for the JPEG compressor. 9 | * This routine is in charge of selecting the modules to be executed and 10 | * making an initialization call to each one. 11 | * 12 | * Logically, this code belongs in jcmaster.c. It's split out because 13 | * linking this routine implies linking the entire compression library. 14 | * For a transcoding-only application, we want to be able to use jcmaster.c 15 | * without linking in the whole library. 16 | */ 17 | 18 | #define JPEG_INTERNALS 19 | #include "jinclude.h" 20 | #include "jpeglib.h" 21 | 22 | 23 | /* 24 | * Master selection of compression modules. 25 | * This is done once at the start of processing an image. We determine 26 | * which modules will be used and give them appropriate initialization calls. 27 | */ 28 | 29 | GLOBAL(void) 30 | jinit_compress_master (j_compress_ptr cinfo) 31 | { 32 | /* Initialize master control (includes parameter checking/processing) */ 33 | jinit_c_master_control(cinfo, FALSE /* full compression */); 34 | 35 | /* Preprocessing */ 36 | if (! cinfo->raw_data_in) { 37 | jinit_color_converter(cinfo); 38 | jinit_downsampler(cinfo); 39 | jinit_c_prep_controller(cinfo, FALSE /* never need full buffer here */); 40 | } 41 | /* Forward DCT */ 42 | jinit_forward_dct(cinfo); 43 | /* Entropy encoding: either Huffman or arithmetic coding. */ 44 | if (cinfo->arith_code) 45 | jinit_arith_encoder(cinfo); 46 | else { 47 | jinit_huff_encoder(cinfo); 48 | } 49 | 50 | /* Need a full-image coefficient buffer in any multi-pass mode. */ 51 | jinit_c_coef_controller(cinfo, 52 | (boolean) (cinfo->num_scans > 1 || cinfo->optimize_coding)); 53 | jinit_c_main_controller(cinfo, FALSE /* never need full buffer here */); 54 | 55 | jinit_marker_writer(cinfo); 56 | 57 | /* We can now tell the memory manager to allocate virtual arrays. */ 58 | (*cinfo->mem->realize_virt_arrays) ((j_common_ptr) cinfo); 59 | 60 | /* Write the datastream header (SOI) immediately. 61 | * Frame and scan headers are postponed till later. 62 | * This lets application insert special markers after the SOI. 63 | */ 64 | (*cinfo->marker->write_file_header) (cinfo); 65 | } 66 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/mutex3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * mutex3.c 3 | * 4 | * 5 | * -------------------------------------------------------------------------- 6 | * 7 | * Pthreads-win32 - POSIX Threads Library for Win32 8 | * Copyright(C) 1998 John E. Bossom 9 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 10 | * 11 | * Contact Email: rpj@callisto.canberra.edu.au 12 | * 13 | * The current list of contributors is contained 14 | * in the file CONTRIBUTORS included with the source 15 | * code distribution. The list can also be seen at the 16 | * following World Wide Web location: 17 | * http://sources.redhat.com/pthreads-win32/contributors.html 18 | * 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; either 22 | * version 2 of the License, or (at your option) any later version. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library in the file COPYING.LIB; 31 | * if not, write to the Free Software Foundation, Inc., 32 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33 | * 34 | * -------------------------------------------------------------------------- 35 | * 36 | * Declare a static mutex object, lock it, trylock it, 37 | * and then unlock it again. 38 | * 39 | * Depends on API functions: 40 | * pthread_mutex_lock() 41 | * pthread_mutex_trylock() 42 | * pthread_mutex_unlock() 43 | */ 44 | 45 | #include "test.h" 46 | 47 | pthread_mutex_t mutex1 = PTHREAD_MUTEX_INITIALIZER; 48 | 49 | static int washere = 0; 50 | 51 | void * func(void * arg) 52 | { 53 | assert(pthread_mutex_trylock(&mutex1) == EBUSY); 54 | 55 | washere = 1; 56 | 57 | return 0; 58 | } 59 | 60 | int 61 | main() 62 | { 63 | pthread_t t; 64 | 65 | assert(pthread_mutex_lock(&mutex1) == 0); 66 | 67 | assert(pthread_create(&t, NULL, func, NULL) == 0); 68 | assert(pthread_join(t, NULL) == 0); 69 | 70 | assert(pthread_mutex_unlock(&mutex1) == 0); 71 | 72 | assert(washere == 1); 73 | 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /third_party/pthread-w32/pthread_barrier_init.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pthread_barrier_init.c 3 | * 4 | * Description: 5 | * This translation unit implements barrier primitives. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | 40 | 41 | int 42 | pthread_barrier_init (pthread_barrier_t * barrier, 43 | const pthread_barrierattr_t * attr, unsigned int count) 44 | { 45 | pthread_barrier_t b; 46 | 47 | if (barrier == NULL || count == 0) 48 | { 49 | return EINVAL; 50 | } 51 | 52 | if (NULL != (b = (pthread_barrier_t) calloc (1, sizeof (*b)))) 53 | { 54 | b->pshared = (attr != NULL && *attr != NULL 55 | ? (*attr)->pshared : PTHREAD_PROCESS_PRIVATE); 56 | 57 | b->nCurrentBarrierHeight = b->nInitialBarrierHeight = count; 58 | b->lock = 0; 59 | 60 | if (0 == sem_init (&(b->semBarrierBreeched), b->pshared, 0)) 61 | { 62 | *barrier = b; 63 | return 0; 64 | } 65 | (void) free (b); 66 | } 67 | 68 | return ENOMEM; 69 | } 70 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/mutex3e.c: -------------------------------------------------------------------------------- 1 | /* 2 | * mutex3e.c 3 | * 4 | * 5 | * -------------------------------------------------------------------------- 6 | * 7 | * Pthreads-win32 - POSIX Threads Library for Win32 8 | * Copyright(C) 1998 John E. Bossom 9 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 10 | * 11 | * Contact Email: rpj@callisto.canberra.edu.au 12 | * 13 | * The current list of contributors is contained 14 | * in the file CONTRIBUTORS included with the source 15 | * code distribution. The list can also be seen at the 16 | * following World Wide Web location: 17 | * http://sources.redhat.com/pthreads-win32/contributors.html 18 | * 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; either 22 | * version 2 of the License, or (at your option) any later version. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library in the file COPYING.LIB; 31 | * if not, write to the Free Software Foundation, Inc., 32 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33 | * 34 | * -------------------------------------------------------------------------- 35 | * 36 | * Declare a static mutex object, lock it, trylock it, 37 | * and then unlock it again. 38 | * 39 | * Depends on API functions: 40 | * pthread_mutex_lock() 41 | * pthread_mutex_trylock() 42 | * pthread_mutex_unlock() 43 | */ 44 | 45 | #include "test.h" 46 | 47 | pthread_mutex_t mutex1 = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER; 48 | 49 | static int washere = 0; 50 | 51 | void * func(void * arg) 52 | { 53 | assert(pthread_mutex_trylock(&mutex1) == EBUSY); 54 | 55 | washere = 1; 56 | 57 | return 0; 58 | } 59 | 60 | int 61 | main() 62 | { 63 | pthread_t t; 64 | 65 | assert(pthread_mutex_lock(&mutex1) == 0); 66 | 67 | assert(pthread_create(&t, NULL, func, NULL) == 0); 68 | assert(pthread_join(t, NULL) == 0); 69 | 70 | assert(pthread_mutex_unlock(&mutex1) == 0); 71 | 72 | assert(washere == 1); 73 | 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/mutex3r.c: -------------------------------------------------------------------------------- 1 | /* 2 | * mutex3r.c 3 | * 4 | * 5 | * -------------------------------------------------------------------------- 6 | * 7 | * Pthreads-win32 - POSIX Threads Library for Win32 8 | * Copyright(C) 1998 John E. Bossom 9 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 10 | * 11 | * Contact Email: rpj@callisto.canberra.edu.au 12 | * 13 | * The current list of contributors is contained 14 | * in the file CONTRIBUTORS included with the source 15 | * code distribution. The list can also be seen at the 16 | * following World Wide Web location: 17 | * http://sources.redhat.com/pthreads-win32/contributors.html 18 | * 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; either 22 | * version 2 of the License, or (at your option) any later version. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library in the file COPYING.LIB; 31 | * if not, write to the Free Software Foundation, Inc., 32 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33 | * 34 | * -------------------------------------------------------------------------- 35 | * 36 | * Declare a static mutex object, lock it, trylock it, 37 | * and then unlock it again. 38 | * 39 | * Depends on API functions: 40 | * pthread_mutex_lock() 41 | * pthread_mutex_trylock() 42 | * pthread_mutex_unlock() 43 | */ 44 | 45 | #include "test.h" 46 | 47 | pthread_mutex_t mutex1 = PTHREAD_RECURSIVE_MUTEX_INITIALIZER; 48 | 49 | static int washere = 0; 50 | 51 | void * func(void * arg) 52 | { 53 | assert(pthread_mutex_trylock(&mutex1) == EBUSY); 54 | 55 | washere = 1; 56 | 57 | return 0; 58 | } 59 | 60 | int 61 | main() 62 | { 63 | pthread_t t; 64 | 65 | assert(pthread_mutex_lock(&mutex1) == 0); 66 | 67 | assert(pthread_create(&t, NULL, func, NULL) == 0); 68 | assert(pthread_join(t, NULL) == 0); 69 | 70 | assert(pthread_mutex_unlock(&mutex1) == 0); 71 | 72 | assert(washere == 1); 73 | 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/kill1.c: -------------------------------------------------------------------------------- 1 | /* 2 | * File: kill1.c 3 | * 4 | * 5 | * -------------------------------------------------------------------------- 6 | * 7 | * Pthreads-win32 - POSIX Threads Library for Win32 8 | * Copyright(C) 1998 John E. Bossom 9 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 10 | * 11 | * Contact Email: rpj@callisto.canberra.edu.au 12 | * 13 | * The current list of contributors is contained 14 | * in the file CONTRIBUTORS included with the source 15 | * code distribution. The list can also be seen at the 16 | * following World Wide Web location: 17 | * http://sources.redhat.com/pthreads-win32/contributors.html 18 | * 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; either 22 | * version 2 of the License, or (at your option) any later version. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library in the file COPYING.LIB; 31 | * if not, write to the Free Software Foundation, Inc., 32 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33 | * 34 | * -------------------------------------------------------------------------- 35 | * 36 | * Test Synopsis: 37 | * - pthread_kill() does not support non zero signals.. 38 | * 39 | * Test Method (Validation or Falsification): 40 | * - 41 | * 42 | * Requirements Tested: 43 | * - 44 | * 45 | * Features Tested: 46 | * - 47 | * 48 | * Cases Tested: 49 | * - 50 | * 51 | * Description: 52 | * - 53 | * 54 | * Environment: 55 | * - 56 | * 57 | * Input: 58 | * - None. 59 | * 60 | * Output: 61 | * - File name, Line number, and failed expression on failure. 62 | * - No output on success. 63 | * 64 | * Assumptions: 65 | * - 66 | * 67 | * Pass Criteria: 68 | * - Process returns zero exit status. 69 | * 70 | * Fail Criteria: 71 | * - Process returns non-zero exit status. 72 | */ 73 | 74 | #include "test.h" 75 | 76 | 77 | int 78 | main() 79 | { 80 | assert(pthread_kill(pthread_self(), 1) == EINVAL); 81 | 82 | return 0; 83 | } 84 | -------------------------------------------------------------------------------- /third_party/pthread-w32/pthread_spin_unlock.c: -------------------------------------------------------------------------------- 1 | /* 2 | * pthread_spin_unlock.c 3 | * 4 | * Description: 5 | * This translation unit implements spin lock primitives. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #include "pthread.h" 38 | #include "implement.h" 39 | 40 | 41 | int 42 | pthread_spin_unlock (pthread_spinlock_t * lock) 43 | { 44 | register pthread_spinlock_t s; 45 | 46 | if (NULL == lock || NULL == *lock) 47 | { 48 | return (EINVAL); 49 | } 50 | 51 | s = *lock; 52 | 53 | if (s == PTHREAD_SPINLOCK_INITIALIZER) 54 | { 55 | return EPERM; 56 | } 57 | 58 | switch ((long) 59 | PTW32_INTERLOCKED_COMPARE_EXCHANGE_LONG ((PTW32_INTERLOCKED_LONGPTR) &s->interlock, 60 | (PTW32_INTERLOCKED_LONG) PTW32_SPIN_UNLOCKED, 61 | (PTW32_INTERLOCKED_LONG) PTW32_SPIN_LOCKED)) 62 | { 63 | case PTW32_SPIN_LOCKED: 64 | case PTW32_SPIN_UNLOCKED: 65 | return 0; 66 | case PTW32_SPIN_USE_MUTEX: 67 | return pthread_mutex_unlock (&(s->u.mutex)); 68 | } 69 | 70 | return EINVAL; 71 | } 72 | -------------------------------------------------------------------------------- /third_party/pthread-w32/tests/join3.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Test for pthread_join() returning return value from threads. 3 | * 4 | * 5 | * -------------------------------------------------------------------------- 6 | * 7 | * Pthreads-win32 - POSIX Threads Library for Win32 8 | * Copyright(C) 1998 John E. Bossom 9 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 10 | * 11 | * Contact Email: rpj@callisto.canberra.edu.au 12 | * 13 | * The current list of contributors is contained 14 | * in the file CONTRIBUTORS included with the source 15 | * code distribution. The list can also be seen at the 16 | * following World Wide Web location: 17 | * http://sources.redhat.com/pthreads-win32/contributors.html 18 | * 19 | * This library is free software; you can redistribute it and/or 20 | * modify it under the terms of the GNU Lesser General Public 21 | * License as published by the Free Software Foundation; either 22 | * version 2 of the License, or (at your option) any later version. 23 | * 24 | * This library is distributed in the hope that it will be useful, 25 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 27 | * Lesser General Public License for more details. 28 | * 29 | * You should have received a copy of the GNU Lesser General Public 30 | * License along with this library in the file COPYING.LIB; 31 | * if not, write to the Free Software Foundation, Inc., 32 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 33 | * 34 | * -------------------------------------------------------------------------- 35 | * 36 | * Depends on API functions: pthread_create(). 37 | */ 38 | 39 | #include "test.h" 40 | 41 | void * 42 | func(void * arg) 43 | { 44 | sched_yield(); 45 | return arg; 46 | } 47 | 48 | int 49 | main(int argc, char * argv[]) 50 | { 51 | pthread_t id[4]; 52 | int i; 53 | void* result = (void*)-1; 54 | 55 | /* Create a few threads and then exit. */ 56 | for (i = 0; i < 4; i++) 57 | { 58 | assert(pthread_create(&id[i], NULL, func, (void *)(size_t)i) == 0); 59 | } 60 | 61 | /* 62 | * Let threads exit before we join them. 63 | * We should still retrieve the exit code for the threads. 64 | */ 65 | Sleep(1000); 66 | 67 | for (i = 0; i < 4; i++) 68 | { 69 | assert(pthread_join(id[i], &result) == 0); 70 | assert((int)(size_t)result == i); 71 | } 72 | 73 | /* Success. */ 74 | return 0; 75 | } 76 | -------------------------------------------------------------------------------- /third_party/pthread-w32/README.Watcom: -------------------------------------------------------------------------------- 1 | Watcom compiler notes 2 | ===================== 3 | 4 | Status 5 | ------ 6 | Not yet usable. Although the library builds under Watcom it 7 | substantially fails the test suite. 8 | 9 | There is a working Wmakefile for wmake for the library build. 10 | 11 | invoke as any of: 12 | wmake -f Wmakefile clean WC 13 | wmake -f Wmakefile clean WC-inlined 14 | wmake -f Wmakefile clean WCE 15 | wmake -f Wmakefile clean WCE-inlined 16 | 17 | These build pthreadWC.dll and pthreadWCE.dll. 18 | 19 | There is a working Wmakefile for wmake for the test suite. 20 | 21 | invoke as any of: 22 | wmake -f Wmakefile clean WC 23 | wmake -f Wmakefile clean WCX 24 | wmake -f Wmakefile clean WCE 25 | wmake -f Wmakefile clean WC-bench 26 | wmake -f Wmakefile clean WCX-bench 27 | wmake -f Wmakefile clean WCE-bench 28 | 29 | 30 | Current known problems 31 | ---------------------- 32 | 33 | Library build: 34 | The Watcom compiler uses a different default call convention to MS C or GNU C and so 35 | applications are not compatible with pthreadVC.dll etc using pre 2003-10-14 versions 36 | of pthread.h, sched.h, or semaphore.h. The cdecl attribute can be used on exposed 37 | function prototypes to force compatibility with MS C built DLLs. 38 | 39 | However, there appear to be other incompatibilities. Errno.h, for example, defines 40 | different values for the standard C and POSIX errors to those defined by the MS C 41 | errno.h. It may be that references to Watcom's threads compatible 'errno' do set 42 | and return translated numbers consistently, but I have not verified this. 43 | 44 | Watcom defines errno as a dereferenced pointer returned by the function 45 | _get_errno_ptr(). This is similar to both the MS and GNU C environments for 46 | multithreaded use. However, the Watcom version appears to have a number of problems: 47 | 48 | - different threads return the same pointer value. Compare with the MS and GNU C 49 | versions which correctly return different values (since each thread must maintain 50 | a thread specific errno value). 51 | 52 | - an errno value set within the DLL appears as zero in the application even though 53 | both share the same thread. 54 | 55 | Therefore applications built using the Watcom compiler may need to use 56 | a Watcom built version of the library (pthreadWC.dll). If this is the case, then 57 | the cdecl function attribute should not be required. 58 | 59 | Application builds: 60 | The test suite fails with the Watcom compiler. 61 | 62 | Test semaphore1.c fails for pthreadWC.dll because errno returns 0 instead of EAGAIN. 63 | -------------------------------------------------------------------------------- /third_party/pthread-w32/mutex.c: -------------------------------------------------------------------------------- 1 | /* 2 | * mutex.c 3 | * 4 | * Description: 5 | * This translation unit implements mutual exclusion (mutex) primitives. 6 | * 7 | * -------------------------------------------------------------------------- 8 | * 9 | * Pthreads-win32 - POSIX Threads Library for Win32 10 | * Copyright(C) 1998 John E. Bossom 11 | * Copyright(C) 1999,2005 Pthreads-win32 contributors 12 | * 13 | * Contact Email: rpj@callisto.canberra.edu.au 14 | * 15 | * The current list of contributors is contained 16 | * in the file CONTRIBUTORS included with the source 17 | * code distribution. The list can also be seen at the 18 | * following World Wide Web location: 19 | * http://sources.redhat.com/pthreads-win32/contributors.html 20 | * 21 | * This library is free software; you can redistribute it and/or 22 | * modify it under the terms of the GNU Lesser General Public 23 | * License as published by the Free Software Foundation; either 24 | * version 2 of the License, or (at your option) any later version. 25 | * 26 | * This library is distributed in the hope that it will be useful, 27 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 29 | * Lesser General Public License for more details. 30 | * 31 | * You should have received a copy of the GNU Lesser General Public 32 | * License along with this library in the file COPYING.LIB; 33 | * if not, write to the Free Software Foundation, Inc., 34 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 35 | */ 36 | 37 | #if ! defined(_UWIN) && ! defined(WINCE) 38 | # include 39 | #endif 40 | #if !defined(NEED_FTIME) 41 | #include 42 | #endif 43 | #include "pthread.h" 44 | #include "implement.h" 45 | 46 | 47 | #include "ptw32_mutex_check_need_init.c" 48 | #include "pthread_mutex_init.c" 49 | #include "pthread_mutex_destroy.c" 50 | #include "pthread_mutexattr_init.c" 51 | #include "pthread_mutexattr_destroy.c" 52 | #include "pthread_mutexattr_getpshared.c" 53 | #include "pthread_mutexattr_setpshared.c" 54 | #include "pthread_mutexattr_settype.c" 55 | #include "pthread_mutexattr_gettype.c" 56 | #include "pthread_mutexattr_setrobust.c" 57 | #include "pthread_mutexattr_getrobust.c" 58 | #include "pthread_mutex_lock.c" 59 | #include "pthread_mutex_timedlock.c" 60 | #include "pthread_mutex_unlock.c" 61 | #include "pthread_mutex_trylock.c" 62 | #include "pthread_mutex_consistent.c" 63 | -------------------------------------------------------------------------------- /src/PaletteOptimizer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "PaletteOptimizer.h" 5 | 6 | PaletteOptimizer::PaletteOptimizer(size_t width, size_t height) 7 | : palette_size_(0), trans_size_(0) 8 | { 9 | size_ = width * height; 10 | }; 11 | 12 | bool PaletteOptimizer::process32bit(buffer_t src) 13 | { 14 | } 15 | 16 | bool PaletteOptimizer::process24bit(buffer_t src) 17 | { 18 | } 19 | 20 | void PaletteOptimizer::process8bit(buffer_t src , palette_t palette, trans_t trans) 21 | { 22 | boost::unordered_map palette_convert; 23 | boost::unordered_map optimized_palette; 24 | boost::unordered_set usedpalette_; 25 | 26 | for (size_t i = 0; i < size_; i++) 27 | { 28 | usedpalette_.insert(src[i]); 29 | } 30 | boost::unordered_set::iterator it; 31 | 32 | for (size_t i = 0; i < 256; i++) 33 | { 34 | unsigned char c = static_cast(i); 35 | if (usedpalette_.find(c) == usedpalette_.end()) 36 | { 37 | continue; 38 | } 39 | unsigned int color = (palette[i].red << 24) + (palette[i].green << 16) + (palette[i].blue << 8) + trans[i]; 40 | boost::unordered_map::iterator existing = optimized_palette.find(color); 41 | if (existing != optimized_palette.end()) 42 | { 43 | palette_convert[i] = palette_convert[existing->second]; 44 | } 45 | else 46 | { 47 | palette_convert[i] = optimized_palette.size(); 48 | optimized_palette[color] = c; 49 | if (trans[i] != 255) 50 | { 51 | trans_size_++; 52 | } 53 | } 54 | } 55 | dest_.reset(new unsigned char[size_]); 56 | palette_size_ = optimized_palette.size(); 57 | palette_.reset(new png_color[palette_size_]); 58 | trans_.reset(new unsigned char[trans_size_]); 59 | boost::unordered_map::iterator iter; 60 | for (iter = optimized_palette.begin(); iter != optimized_palette.end(); iter++) 61 | { 62 | size_t offset = palette_convert[iter->second]; 63 | palette_[offset] = palette[iter->second]; 64 | if (offset < trans_size_) 65 | { 66 | trans_[offset] = trans[iter->second]; 67 | } 68 | } 69 | for (size_t i = 0; i < size_; i++) 70 | { 71 | dest_[i] = palette_convert[src[i]]; 72 | } 73 | } 74 | 75 | --------------------------------------------------------------------------------