diff options
168 files changed, 8137 insertions, 3657 deletions
@@ -6,7 +6,7 @@ src/relooper*.js node_modules/ -# Ignore generated files +# Ignore generated files src/relooper.js src/relooper.js.raw.js src/relooper/*.o @@ -18,3 +18,4 @@ tests/freetype/objs/*.lo third_party/lzma.js/lzip/*.o third_party/lzma.js/lzma-native +third_party/lzma.js/lzma-native.exe @@ -106,4 +106,5 @@ a license to everyone to use it as detailed in LICENSE.) * Fraser Adams <fraser.adams@blueyonder.co.uk> * Michael Tirado <icetooth333@gmail.com> * Ben Noordhuis <info@bnoordhuis.nl> - +* Bob Roberts <bobroberts177@gmail.com> +* John Vilk <jvilk@cs.umass.edu> diff --git a/CONTRIBUTING.markdown b/CONTRIBUTING.markdown new file mode 100644 index 00000000..ceea8735 --- /dev/null +++ b/CONTRIBUTING.markdown @@ -0,0 +1,5 @@ + +See our wiki for information about contributing to Emscripten: + +[Contribution section on wiki](https://github.com/kripken/emscripten/wiki#contributing) + diff --git a/cmake/Platform/Emscripten.cmake b/cmake/Platform/Emscripten.cmake index 7c8e83fa..e1e54ccf 100644 --- a/cmake/Platform/Emscripten.cmake +++ b/cmake/Platform/Emscripten.cmake @@ -146,6 +146,10 @@ set(link_js_counter 1) # Internal function: Do not call from user CMakeLists.txt files. Use one of em_link_js_library()/em_link_pre_js()/em_link_post_js() instead. function(em_add_tracked_link_flag target flagname) get_target_property(props ${target} LINK_FLAGS) + if(NOT props) + set(props "") + endif() + # User can input list of JS files either as a single list, or as variable arguments to this function, so iterate over varargs, and treat each # item in varargs as a list itself, to support both syntax forms. foreach(jsFileList ${ARGN}) @@ -8,7 +8,5 @@ import os, subprocess, sys from tools import shared os.environ['EMMAKEN_CXX'] = '1' -if not os.path.exists(shared.PYTHON): - print >> sys.stderr, 'warning: PYTHON does not seem to be defined properly in ~/.emscripten (%s)' % shared.PYTHON exit(subprocess.call([shared.PYTHON, shared.EMCC] + sys.argv[1:])) @@ -777,6 +777,7 @@ try: save_bc = False memory_init_file = False use_preload_cache = False + no_heap_copy = False proxy_to_worker = False if use_cxx: @@ -897,6 +898,9 @@ try: elif newargs[i].startswith('--use-preload-cache'): use_preload_cache = True newargs[i] = '' + elif newargs[i].startswith('--no-heap-copy'): + no_heap_copy = True + newargs[i] = '' elif newargs[i] == '--ignore-dynamic-linking': ignore_dynamic_linking = True newargs[i] = '' @@ -1129,10 +1133,11 @@ try: heap = 4096 while heap < shared.Settings.TOTAL_MEMORY: - if heap <= 16*1024*1024: - heap *= 2 - else: - heap += 16*1024*1024 + heap *= 2 + #if heap <= 16*1024*1024: + # heap *= 2 + #else: + # heap += 16*1024*1024 if heap != shared.Settings.TOTAL_MEMORY: logging.warning('increasing TOTAL_MEMORY to %d to be more reasonable for asm.js' % heap) shared.Settings.TOTAL_MEMORY = heap @@ -1673,6 +1678,8 @@ try: file_args += ['--compress', Compression.encoder, Compression.decoder, Compression.js_name] if use_preload_cache: file_args.append('--use-preload-cache') + if no_heap_copy: + file_args.append('--no-heap-copy') file_code = execute([shared.PYTHON, shared.FILE_PACKAGER, unsuffixed(target) + '.data'] + file_args, stdout=PIPE)[0] pre_js = file_code + pre_js diff --git a/emscripten.py b/emscripten.py index dbea6eb2..75e6711a 100755 --- a/emscripten.py +++ b/emscripten.py @@ -11,6 +11,7 @@ headers, for the libc implementation in JS). import os, sys, json, optparse, subprocess, re, time, multiprocessing, string, logging +from tools import shared from tools import jsrun, cache as cache_module, tempfiles from tools.response_file import read_response_file @@ -25,7 +26,6 @@ def get_configuration(): if hasattr(get_configuration, 'configuration'): return get_configuration.configuration - from tools import shared configuration = shared.Configuration(environ=os.environ) get_configuration.configuration = configuration return configuration @@ -117,7 +117,7 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None, last = func_start func_start = ll.find('\ndefine ', func_start) if func_start > last: - pre.append(ll[last:min(func_start+1, meta_start)] + '\n') + pre.append(ll[last:min(func_start+1, meta_start) if meta_start > 0 else func_start+1] + '\n') if func_start < 0: pre.append(ll[last:meta_start] + '\n') break @@ -425,8 +425,8 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None, Counter.i += 1 bad = 'b' + str(i) params = ','.join(['p%d' % p for p in range(len(sig)-1)]) - coercions = ';'.join(['p%d = %sp%d%s' % (p, '+' if sig[p+1] != 'i' else '', p, '' if sig[p+1] != 'i' else '|0') for p in range(len(sig)-1)]) + ';' - ret = '' if sig[0] == 'v' else ('return %s0' % ('+' if sig[0] != 'i' else '')) + coercions = ';'.join(['p%d = %s' % (p, shared.JS.make_coercion('p%d' % p, sig[p+1], settings)) for p in range(len(sig)-1)]) + ';' + ret = '' if sig[0] == 'v' else ('return %s' % shared.JS.make_initializer(sig[0], settings)) start = raw.index('[') end = raw.rindex(']') body = raw[start+1:end].split(',') @@ -451,7 +451,7 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None, math_envs = ['Math.min'] # TODO: move min to maths asm_setup += '\n'.join(['var %s = %s;' % (f.replace('.', '_'), f) for f in math_envs]) - if settings['TO_FLOAT32']: maths += ['Math.toFloat32'] + if settings['PRECISE_F32']: maths += ['Math.fround'] basic_funcs = ['abort', 'assert', 'asmPrintInt', 'asmPrintFloat'] + [m.replace('.', '_') for m in math_envs] if settings['RESERVED_FUNCTION_POINTERS'] > 0: basic_funcs.append('jsCall') @@ -476,18 +476,14 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None, asm_runtime_funcs = ['stackAlloc', 'stackSave', 'stackRestore', 'setThrew'] + ['setTempRet%d' % i for i in range(10)] # function tables - def asm_coerce(value, sig): - if sig == 'v': return value - return ('+' if sig != 'i' else '') + value + ('|0' if sig == 'i' else '') - function_tables = ['dynCall_' + table for table in last_forwarded_json['Functions']['tables']] function_tables_impls = [] for sig in last_forwarded_json['Functions']['tables'].iterkeys(): args = ','.join(['a' + str(i) for i in range(1, len(sig))]) - arg_coercions = ' '.join(['a' + str(i) + '=' + asm_coerce('a' + str(i), sig[i]) + ';' for i in range(1, len(sig))]) - coerced_args = ','.join([asm_coerce('a' + str(i), sig[i]) for i in range(1, len(sig))]) - ret = ('return ' if sig[0] != 'v' else '') + asm_coerce('FUNCTION_TABLE_%s[index&{{{ FTM_%s }}}](%s)' % (sig, sig, coerced_args), sig[0]) + arg_coercions = ' '.join(['a' + str(i) + '=' + shared.JS.make_coercion('a' + str(i), sig[i], settings) + ';' for i in range(1, len(sig))]) + coerced_args = ','.join([shared.JS.make_coercion('a' + str(i), sig[i], settings) for i in range(1, len(sig))]) + ret = ('return ' if sig[0] != 'v' else '') + shared.JS.make_coercion('FUNCTION_TABLE_%s[index&{{{ FTM_%s }}}](%s)' % (sig, sig, coerced_args), sig[0], settings) function_tables_impls.append(''' function dynCall_%s(index%s%s) { index = index|0; @@ -497,7 +493,7 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None, ''' % (sig, ',' if len(sig) > 1 else '', args, arg_coercions, ret)) for i in range(settings['RESERVED_FUNCTION_POINTERS']): - jsret = ('return ' if sig[0] != 'v' else '') + asm_coerce('jsCall(%d%s%s)' % (i, ',' if coerced_args else '', coerced_args), sig[0]) + jsret = ('return ' if sig[0] != 'v' else '') + shared.JS.make_coercion('jsCall(%d%s%s)' % (i, ',' if coerced_args else '', coerced_args), sig[0], settings) function_tables_impls.append(''' function jsCall_%s_%s(%s) { %s @@ -505,7 +501,6 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None, } ''' % (sig, i, args, arg_coercions, jsret)) - from tools import shared shared.Settings.copy(settings) asm_setup += '\n' + shared.JS.make_invoke(sig) + '\n' basic_funcs.append('invoke_%s' % sig) @@ -578,14 +573,14 @@ var asm = (function(global, env, buffer) { var HEAPU32 = new global.Uint32Array(buffer); var HEAPF32 = new global.Float32Array(buffer); var HEAPF64 = new global.Float64Array(buffer); -''' % (asm_setup, "'use asm';" if not forwarded_json['Types']['hasInlineJS'] and not settings['SIDE_MODULE'] else "'almost asm';") + '\n' + asm_global_vars + ''' +''' % (asm_setup, "'use asm';" if not forwarded_json['Types']['hasInlineJS'] and not settings['SIDE_MODULE'] and settings['ASM_JS'] == 1 else "'almost asm';") + '\n' + asm_global_vars + ''' var __THREW__ = 0; var threwValue = 0; var setjmpId = 0; var undef = 0; var tempInt = 0, tempBigInt = 0, tempBigIntP = 0, tempBigIntS = 0, tempBigIntR = 0.0, tempBigIntI = 0, tempBigIntD = 0, tempValue = 0, tempDouble = 0.0; ''' + ''.join([''' - var tempRet%d = 0;''' % i for i in range(10)]) + '\n' + asm_global_funcs + ''' + var tempRet%d = 0;''' % i for i in range(10)]) + '\n' + asm_global_funcs] + [' var tempFloat = %s;\n' % ('Math_fround(0)' if settings.get('PRECISE_F32') else '0.0')] + [''' // EMSCRIPTEN_START_FUNCS function stackAlloc(size) { size = size|0; @@ -727,14 +722,12 @@ def main(args, compiler_engine, cache, jcache, relooper, temp_files, DEBUG, DEBU relooper = cache.get_path('relooper.js') settings.setdefault('RELOOPER', relooper) if not os.path.exists(relooper): - from tools import shared shared.Building.ensure_relooper(relooper) settings.setdefault('STRUCT_INFO', cache.get_path('struct_info.compiled.json')) struct_info = settings.get('STRUCT_INFO') if not os.path.exists(struct_info): - from tools import shared shared.Building.ensure_struct_info(struct_info) emscript(args.infile, settings, args.outfile, libraries, compiler_engine=compiler_engine, @@ -833,7 +826,6 @@ WARNING: You should normally never use this! Use emcc instead. temp_files = tempfiles.TempFiles(temp_dir) if keywords.compiler is None: - from tools import shared keywords.compiler = shared.COMPILER_ENGINE if keywords.verbose is None: diff --git a/src/intertyper.js b/src/intertyper.js index fceeb38d..fa53c652 100644 --- a/src/intertyper.js +++ b/src/intertyper.js @@ -680,6 +680,9 @@ function intertyper(lines, sidePass, baseLineNums) { args.push(ident); }); } + item.ident = expandLLVMString(item.ident).replace(/(#[^\n]*)/g, function(m) { + return '/* ' + m.substr(1) + ' */'; // fix asm comments to js comments + }); if (item.assignTo) item.ident = 'return ' + item.ident; item.ident = '(function(' + params + ') { ' + item.ident + ' })(' + args + ');'; return { ret: item, item: item }; diff --git a/src/jsifier.js b/src/jsifier.js index 0da48a8c..22a230ca 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -490,10 +490,15 @@ function JSify(data, functionsOnly, givenFunctions) { } else { // If this is not linkable, anything not in the library is definitely missing var cancel = false; + if (item.ident in DEAD_FUNCTIONS) { + LibraryManager.library[shortident] = new Function("Module['printErr']('dead function: " + shortident + "'); abort(-1);"); + delete LibraryManager.library[shortident + '__inline']; + delete LibraryManager.library[shortident + '__deps']; + } if (!LINKABLE && !LibraryManager.library.hasOwnProperty(shortident) && !LibraryManager.library.hasOwnProperty(shortident + '__inline')) { if (ERROR_ON_UNDEFINED_SYMBOLS) error('unresolved symbol: ' + shortident); - if (VERBOSE || WARN_ON_UNDEFINED_SYMBOLS) printErr('warning: unresolved symbol: ' + shortident); - if (ASM_JS || item.ident in DEAD_FUNCTIONS) { + else if (VERBOSE || WARN_ON_UNDEFINED_SYMBOLS) warn('unresolved symbol: ' + shortident); + if (ASM_JS) { // emit a stub that will fail during runtime. this allows asm validation to succeed. LibraryManager.library[shortident] = new Function("Module['printErr']('missing function: " + shortident + "'); abort(-1);"); } else { @@ -756,14 +761,7 @@ function JSify(data, functionsOnly, givenFunctions) { if (func.setjmpTable && !ASM_JS) { ret += ' } catch(e) { if (!e.longjmp || !(e.id in mySetjmpIds)) throw(e); setjmpTable[setjmpLabels[e.id]](e.value) }'; } - if (ASM_JS && func.returnType !== 'void') { - // Add a return - if (func.returnType in Runtime.FLOAT_TYPES) { - ret += ' return +0;\n'; - } else { - ret += ' return 0;\n'; - } - } + if (ASM_JS && func.returnType !== 'void') ret += ' return ' + asmInitializer(func.returnType) + ';\n'; // Add a return } else { ret += (SHOW_LABELS ? indent + '/* ' + block.entries[0] + ' */' : '') + '\n' + getLabelLines(block.labels[0]); } @@ -833,11 +831,7 @@ function JSify(data, functionsOnly, givenFunctions) { var lastReturn = func.JS.lastIndexOf('return '); if ((lastCurly < 0 && lastReturn < 0) || // no control flow, no return (lastCurly >= 0 && lastReturn < lastCurly)) { // control flow, no return past last join - if (func.returnType in Runtime.FLOAT_TYPES) { - func.JS += ' return +0;\n'; - } else { - func.JS += ' return 0;\n'; - } + func.JS += ' return ' + asmInitializer(func.returnType) + ';\n'; } } func.JS += '}\n'; @@ -1337,7 +1331,7 @@ function JSify(data, functionsOnly, givenFunctions) { if (isNumber(item.ident)) { // Direct read from a memory address; this may be an intentional segfault, if not, it is a bug in the source if (ASM_JS) { - return asmCoercion('abort(' + item.ident + ')', item.type); + return asmFFICoercion('abort(' + item.ident + ')', item.type); } else { item.assignTo = null; return 'throw "fault on read from ' + item.ident + '";'; @@ -1514,8 +1508,10 @@ function JSify(data, functionsOnly, givenFunctions) { args = args.map(function(arg, i) { return indexizeFunctions(arg, argsTypes[i]) }); if (ASM_JS) { - if (shortident in Functions.libraryFunctions || simpleIdent in Functions.libraryFunctions || byPointerForced || invoke || extCall || funcData.setjmpTable) { - args = args.map(function(arg, i) { return asmCoercion(arg, argsTypes[i]) }); + var ffiCall = (shortident in Functions.libraryFunctions || simpleIdent in Functions.libraryFunctions || byPointerForced || invoke || extCall || funcData.setjmpTable) && + !(simpleIdent in JS_MATH_BUILTINS); + if (ffiCall) { + args = args.map(function(arg, i) { return asmCoercion(arg, ensureValidFFIType(argsTypes[i])) }); } else { args = args.map(function(arg, i) { return asmEnsureFloat(arg, argsTypes[i]) }); } @@ -1592,7 +1588,7 @@ function JSify(data, functionsOnly, givenFunctions) { returnType = getReturnType(type); if (callIdent in Functions.implementedFunctions) { // LLVM sometimes bitcasts for no reason. We must call using the exact same type as the actual function is generated as - var trueType = Functions.getSignatureReturnType(Functions.implementedFunctions[callIdent]); + var trueType = Functions.getSignatureType(Functions.implementedFunctions[callIdent][0]); if (trueType !== returnType && !isIdenticallyImplemented(trueType, returnType)) { if (VERBOSE) warnOnce('Fixing function call based on return type from signature, on ' + [callIdent, returnType, trueType]); returnType = trueType; @@ -1628,7 +1624,11 @@ function JSify(data, functionsOnly, givenFunctions) { var ret = callIdent + '(' + args.join(',') + ')'; if (ASM_JS) { // TODO: do only when needed (library functions and Math.*?) XXX && simpleIdent in Functions.libraryFunctions) { - ret = asmCoercion(ret, returnType); + if (ffiCall) { + ret = asmFFICoercion(ret, returnType); + } else { + ret = asmCoercion(ret, returnType); + } if (simpleIdent == 'abort' && funcData.returnType != 'void') { ret += '; return ' + asmCoercion('0', funcData.returnType); // special case: abort() can happen without return, breaking the return type of asm functions. ensure a return } diff --git a/src/library.js b/src/library.js index e3cdc7c3..48acf6ac 100644 --- a/src/library.js +++ b/src/library.js @@ -847,10 +847,7 @@ LibraryManager.library = { ___setErrNo(ERRNO_CODES.ERANGE); return 0; } else { - for (var i = 0; i < cwd.length; i++) { - {{{ makeSetValue('buf', 'i', 'cwd.charCodeAt(i)', 'i8') }}} - } - {{{ makeSetValue('buf', 'i', '0', 'i8') }}} + writeAsciiToMemory(cwd, buf); return buf; } }, @@ -1193,7 +1190,6 @@ LibraryManager.library = { _exit: function(status) { // void _exit(int status); // http://pubs.opengroup.org/onlinepubs/000095399/functions/exit.html - Module.print('exit(' + status + ') called'); Module['exit'](status); }, fork__deps: ['__setErrNo', '$ERRNO_CODES'], @@ -1293,10 +1289,7 @@ LibraryManager.library = { if (namesize < ret.length + 1) { return ___setErrNo(ERRNO_CODES.ERANGE); } else { - for (var i = 0; i < ret.length; i++) { - {{{ makeSetValue('name', 'i', 'ret.charCodeAt(i)', 'i8') }}} - } - {{{ makeSetValue('name', 'i', '0', 'i8') }}} + writeAsciiToMemory(ret, name); return 0; } }, @@ -1602,12 +1595,12 @@ LibraryManager.library = { if (format.indexOf('%n') >= 0) { // need to track soFar var _get = get; - get = function() { + get = function get() { soFar++; return _get(); } var _unget = unget; - unget = function() { + unget = function unget() { soFar--; return _unget(); } @@ -2699,10 +2692,7 @@ LibraryManager.library = { var result = dir + '/' + name; if (!_tmpnam.buffer) _tmpnam.buffer = _malloc(256); if (!s) s = _tmpnam.buffer; - for (var i = 0; i < result.length; i++) { - {{{ makeSetValue('s', 'i', 'result.charCodeAt(i)', 'i8') }}}; - } - {{{ makeSetValue('s', 'i', '0', 'i8') }}}; + writeAsciiToMemory(result, s); return s; }, tempnam__deps: ['tmpnam'], @@ -2755,12 +2745,12 @@ LibraryManager.library = { return -1; } var buffer = []; - var get = function() { + function get() { var c = _fgetc(stream); buffer.push(c); return c; }; - var unget = function() { + function unget() { _ungetc(buffer.pop(), stream); }; return __scanString(format, get, unget, varargs); @@ -2777,8 +2767,8 @@ LibraryManager.library = { // int sscanf(const char *restrict s, const char *restrict format, ... ); // http://pubs.opengroup.org/onlinepubs/000095399/functions/scanf.html var index = 0; - var get = function() { return {{{ makeGetValue('s', 'index++', 'i8') }}}; }; - var unget = function() { index--; }; + function get() { return {{{ makeGetValue('s', 'index++', 'i8') }}}; }; + function unget() { index--; }; return __scanString(format, get, unget, varargs); }, snprintf__deps: ['_formatString'], @@ -3040,7 +3030,7 @@ LibraryManager.library = { }, bsearch: function(key, base, num, size, compar) { - var cmp = function(x, y) { + function cmp(x, y) { #if ASM_JS return Module['dynCall_iii'](compar, x, y); #else @@ -3343,10 +3333,7 @@ LibraryManager.library = { var ptrSize = {{{ Runtime.getNativeTypeSize('i8*') }}}; for (var i = 0; i < strings.length; i++) { var line = strings[i]; - for (var j = 0; j < line.length; j++) { - {{{ makeSetValue('poolPtr', 'j', 'line.charCodeAt(j)', 'i8') }}}; - } - {{{ makeSetValue('poolPtr', 'j', '0', 'i8') }}}; + writeAsciiToMemory(line, poolPtr); {{{ makeSetValue('envPtr', 'i * ptrSize', 'poolPtr', 'i8*') }}}; poolPtr += line.length + 1; } @@ -3976,10 +3963,7 @@ LibraryManager.library = { return ___setErrNo(ERRNO_CODES.ERANGE); } else { var msg = ERRNO_MESSAGES[errnum]; - for (var i = 0; i < msg.length; i++) { - {{{ makeSetValue('strerrbuf', 'i', 'msg.charCodeAt(i)', 'i8') }}} - } - {{{ makeSetValue('strerrbuf', 'i', 0, 'i8') }}} + writeAsciiToMemory(msg, strerrbuf); return 0; } } else { @@ -4164,6 +4148,11 @@ LibraryManager.library = { }, // ========================================================================== + // GCC/LLVM specifics + // ========================================================================== + __builtin_prefetch: function(){}, + + // ========================================================================== // LLVM specifics // ========================================================================== @@ -5062,10 +5051,7 @@ LibraryManager.library = { var layout = {{{ JSON.stringify(C_STRUCTS.utsname) }}}; function copyString(element, value) { var offset = layout[element]; - for (var i = 0; i < value.length; i++) { - {{{ makeSetValue('name', 'offset + i', 'value.charCodeAt(i)', 'i8') }}} - } - {{{ makeSetValue('name', 'offset + i', '0', 'i8') }}} + writeAsciiToMemory(value, name + offset); } if (name === 0) { return -1; @@ -5108,7 +5094,7 @@ LibraryManager.library = { table[from + i] = {}; sigs.forEach(function(sig) { // TODO: new Function etc. var full = 'dynCall_' + sig; - table[from + i][sig] = function() { + table[from + i][sig] = function dynCall_sig() { arguments[0] -= from; return asm[full].apply(null, arguments); } @@ -5132,7 +5118,7 @@ LibraryManager.library = { // patch js module dynCall_* to use functionTable sigs.forEach(function(sig) { - jsModule['dynCall_' + sig] = function() { + jsModule['dynCall_' + sig] = function dynCall_sig() { return table[arguments[0]][sig].apply(null, arguments); }; }); @@ -5295,6 +5281,16 @@ LibraryManager.library = { } }, + dladdr: function(addr, info) { + // report all function pointers as coming from this program itself XXX not really correct in any way + var fname = allocate(intArrayFromString("/bin/this.program"), 'i8', ALLOC_NORMAL); // XXX leak + {{{ makeSetValue('addr', 0, 'fname', 'i32') }}}; + {{{ makeSetValue('addr', QUANTUM_SIZE, '0', 'i32') }}}; + {{{ makeSetValue('addr', QUANTUM_SIZE*2, '0', 'i32') }}}; + {{{ makeSetValue('addr', QUANTUM_SIZE*3, '0', 'i32') }}}; + return 1; + }, + // ========================================================================== // pwd.h // ========================================================================== @@ -5596,7 +5592,7 @@ LibraryManager.library = { var WEEKDAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; var MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; - var leadingSomething = function(value, digits, character) { + function leadingSomething(value, digits, character) { var str = typeof value === 'number' ? value.toString() : (value || ''); while (str.length < digits) { str = character[0]+str; @@ -5604,12 +5600,12 @@ LibraryManager.library = { return str; }; - var leadingNulls = function(value, digits) { + function leadingNulls(value, digits) { return leadingSomething(value, digits, '0'); }; - var compareByDay = function(date1, date2) { - var sgn = function(value) { + function compareByDay(date1, date2) { + function sgn(value) { return value < 0 ? -1 : (value > 0 ? 1 : 0); }; @@ -5622,7 +5618,7 @@ LibraryManager.library = { return compare; }; - var getFirstWeekStartDate = function(janFourth) { + function getFirstWeekStartDate(janFourth) { switch (janFourth.getDay()) { case 0: // Sunday return new Date(janFourth.getFullYear()-1, 11, 29); @@ -5641,7 +5637,7 @@ LibraryManager.library = { } }; - var getWeekBasedYear = function(date) { + function getWeekBasedYear(date) { var thisDate = __addDays(new Date(date.tm_year+1900, 0, 1), date.tm_yday); var janFourthThisYear = new Date(thisDate.getFullYear(), 0, 4); @@ -5928,8 +5924,8 @@ LibraryManager.library = { var matches = new RegExp('^'+pattern).exec(Pointer_stringify(buf)) // Module['print'](Pointer_stringify(buf)+ ' is matched by '+((new RegExp('^'+pattern)).source)+' into: '+JSON.stringify(matches)); - var initDate = function() { - var fixup = function(value, min, max) { + function initDate() { + function fixup(value, min, max) { return (typeof value !== 'number' || isNaN(value)) ? min : (value>=min ? (value<=max ? value: max): min); }; return { @@ -5946,7 +5942,7 @@ LibraryManager.library = { var date = initDate(); var value; - var getMatch = function(symbol) { + function getMatch(symbol) { var pos = capture.indexOf(symbol); // check if symbol appears in regexp if (pos >= 0) { @@ -6116,8 +6112,10 @@ LibraryManager.library = { // int nanosleep(const struct timespec *rqtp, struct timespec *rmtp); var seconds = {{{ makeGetValue('rqtp', C_STRUCTS.timespec.tv_sec, 'i32') }}}; var nanoseconds = {{{ makeGetValue('rqtp', C_STRUCTS.timespec.tv_nsec, 'i32') }}}; - {{{ makeSetValue('rmtp', C_STRUCTS.timespec.tv_sec, '0', 'i32') }}} - {{{ makeSetValue('rmtp', C_STRUCTS.timespec.tv_nsec, '0', 'i32') }}} + if (rmtp !== 0) { + {{{ makeSetValue('rmtp', C_STRUCTS.timespec.tv_sec, '0', 'i32') }}} + {{{ makeSetValue('rmtp', C_STRUCTS.timespec.tv_nsec, '0', 'i32') }}} + } return _usleep((seconds * 1e6) + (nanoseconds / 1000)); }, // TODO: Implement these for real. @@ -6557,10 +6555,7 @@ LibraryManager.library = { var me = _nl_langinfo; if (!me.ret) me.ret = _malloc(32); - for (var i = 0; i < result.length; i++) { - {{{ makeSetValue('me.ret', 'i', 'result.charCodeAt(i)', 'i8') }}} - } - {{{ makeSetValue('me.ret', 'i', '0', 'i8') }}} + writeAsciiToMemory(result, me.ret); return me.ret; }, @@ -6876,6 +6871,10 @@ LibraryManager.library = { pthread_mutex_trylock: function() { return 0; }, + pthread_mutexattr_setpshared: function(attr, pshared) { + // XXX implement if/when getpshared is required + return 0; + }, pthread_cond_init: function() {}, pthread_cond_destroy: function() {}, pthread_cond_broadcast: function() { @@ -6971,6 +6970,10 @@ LibraryManager.library = { _pthread_cleanup_push.level = __ATEXIT__.length; }, + pthread_rwlock_init: function() { + return 0; // XXX + }, + // ========================================================================== // malloc.h // ========================================================================== @@ -7312,6 +7315,7 @@ LibraryManager.library = { // we're generating fake IP addresses with lookup_name that we can // resolve later on with lookup_addr. // We do the aliasing in 172.29.*.*, giving us 65536 possibilities. + $DNS__deps: ['_inet_pton4_raw', '_inet_pton6_raw'], $DNS: { address_map: { id: 1, @@ -7319,7 +7323,6 @@ LibraryManager.library = { names: {} }, - lookup_name__deps: ['_inet_pton4_raw', '_inet_pton6_raw'], lookup_name: function (name) { // If the name is already a valid ipv4 / ipv6 address, don't generate a fake one. var res = __inet_pton4_raw(name); @@ -7410,6 +7413,9 @@ LibraryManager.library = { getaddrinfo__deps: ['$Sockets', '$DNS', '_inet_pton4_raw', '_inet_ntop4_raw', '_inet_pton6_raw', '_inet_ntop6_raw', '_write_sockaddr', 'htonl'], getaddrinfo: function(node, service, hint, out) { + // Note getaddrinfo currently only returns a single addrinfo with ai_next defaulting to NULL. When NULL + // hints are specified or ai_family set to AF_UNSPEC or ai_socktype or ai_protocol set to 0 then we + // really should provide a linked list of suitable addrinfo values. var addrs = []; var canon = null; var addr = 0; @@ -7464,6 +7470,15 @@ LibraryManager.library = { type = proto === {{{ cDefine('IPPROTO_UDP') }}} ? {{{ cDefine('SOCK_DGRAM') }}} : {{{ cDefine('SOCK_STREAM') }}}; } + // If type or proto are set to zero in hints we should really be returning multiple addrinfo values, but for + // now default to a TCP STREAM socket so we can at least return a sensible addrinfo given NULL hints. + if (proto === 0) { + proto = {{{ cDefine('IPPROTO_TCP') }}}; + } + if (type === 0) { + type = {{{ cDefine('SOCK_STREAM') }}}; + } + if (!node && !service) { return {{{ cDefine('EAI_NONAME') }}}; } @@ -7471,14 +7486,14 @@ LibraryManager.library = { {{{ cDefine('AI_NUMERICSERV') }}}|{{{ cDefine('AI_V4MAPPED') }}}|{{{ cDefine('AI_ALL') }}}|{{{ cDefine('AI_ADDRCONFIG') }}})) { return {{{ cDefine('EAI_BADFLAGS') }}}; } - if (({{{ makeGetValue('hint', C_STRUCTS.addrinfo.ai_flags, 'i32') }}} & {{{ cDefine('AI_CANONNAME') }}}) && !node) { + if (hint !== 0 && ({{{ makeGetValue('hint', C_STRUCTS.addrinfo.ai_flags, 'i32') }}} & {{{ cDefine('AI_CANONNAME') }}}) && !node) { return {{{ cDefine('EAI_BADFLAGS') }}}; } if (flags & {{{ cDefine('AI_ADDRCONFIG') }}}) { // TODO return {{{ cDefine('EAI_NONAME') }}}; } - if (type !== {{{ cDefine('SOCK_STREAM') }}} && type !== {{{ cDefine('SOCK_DGRAM') }}}) { + if (type !== 0 && type !== {{{ cDefine('SOCK_STREAM') }}} && type !== {{{ cDefine('SOCK_DGRAM') }}}) { return {{{ cDefine('EAI_SOCKTYPE') }}}; } if (family !== {{{ cDefine('AF_UNSPEC') }}} && family !== {{{ cDefine('AF_INET') }}} && family !== {{{ cDefine('AF_INET6') }}}) { @@ -7608,12 +7623,43 @@ LibraryManager.library = { return 0; }, + // Can't use a literal for $GAI_ERRNO_MESSAGES as was done for $ERRNO_MESSAGES as the keys (e.g. EAI_BADFLAGS) + // are actually negative numbers and you can't have expressions as keys in JavaScript literals. + $GAI_ERRNO_MESSAGES: {}, + gai_strerror__deps: ['$GAI_ERRNO_MESSAGES'], gai_strerror: function(val) { - if (!_gai_strerror.error) { - _gai_strerror.error = allocate(intArrayFromString("unknown error"), 'i8', ALLOC_NORMAL); + var buflen = 256; + + // On first call to gai_strerror we initialise the buffer and populate the error messages. + if (!_gai_strerror.buffer) { + _gai_strerror.buffer = _malloc(buflen); + + GAI_ERRNO_MESSAGES['0'] = 'Success'; + GAI_ERRNO_MESSAGES['' + {{{ cDefine('EAI_BADFLAGS') }}}] = 'Invalid value for \'ai_flags\' field'; + GAI_ERRNO_MESSAGES['' + {{{ cDefine('EAI_NONAME') }}}] = 'NAME or SERVICE is unknown'; + GAI_ERRNO_MESSAGES['' + {{{ cDefine('EAI_AGAIN') }}}] = 'Temporary failure in name resolution'; + GAI_ERRNO_MESSAGES['' + {{{ cDefine('EAI_FAIL') }}}] = 'Non-recoverable failure in name res'; + GAI_ERRNO_MESSAGES['' + {{{ cDefine('EAI_FAMILY') }}}] = '\'ai_family\' not supported'; + GAI_ERRNO_MESSAGES['' + {{{ cDefine('EAI_SOCKTYPE') }}}] = '\'ai_socktype\' not supported'; + GAI_ERRNO_MESSAGES['' + {{{ cDefine('EAI_SERVICE') }}}] = 'SERVICE not supported for \'ai_socktype\''; + GAI_ERRNO_MESSAGES['' + {{{ cDefine('EAI_MEMORY') }}}] = 'Memory allocation failure'; + GAI_ERRNO_MESSAGES['' + {{{ cDefine('EAI_SYSTEM') }}}] = 'System error returned in \'errno\''; + GAI_ERRNO_MESSAGES['' + {{{ cDefine('EAI_OVERFLOW') }}}] = 'Argument buffer overflow'; + } + + var msg = 'Unknown error'; + + if (val in GAI_ERRNO_MESSAGES) { + if (GAI_ERRNO_MESSAGES[val].length > buflen - 1) { + msg = 'Message too long'; // EMSGSIZE message. This should never occur given the GAI_ERRNO_MESSAGES above. + } else { + msg = GAI_ERRNO_MESSAGES[val]; + } } - return _gai_strerror.error; + + writeAsciiToMemory(msg, _gai_strerror.buffer); + return _gai_strerror.buffer; }, // ========================================================================== @@ -7681,7 +7727,7 @@ LibraryManager.library = { var session = Module['webrtc']['session']; var peer = new Peer(broker); var listenOptions = Module['webrtc']['hostOptions'] || {}; - peer.onconnection = function(connection) { + peer.onconnection = function peer_onconnection(connection) { console.log('connected'); var addr; /* If this peer is connecting to the host, assign 10.0.0.1 to the host so it can be @@ -7695,7 +7741,7 @@ LibraryManager.library = { } connection['addr'] = addr; Sockets.connections[addr] = connection; - connection.ondisconnect = function() { + connection.ondisconnect = function connection_ondisconnect() { console.log('disconnect'); // Don't return the host address (10.0.0.1) to the pool if (!(session && session === Sockets.connections[addr]['route'])) { @@ -7707,12 +7753,12 @@ LibraryManager.library = { Module['webrtc']['ondisconnect'](peer); } }; - connection.onerror = function(error) { + connection.onerror = function connection_onerror(error) { if (Module['webrtc']['onerror'] && 'function' === typeof Module['webrtc']['onerror']) { Module['webrtc']['onerror'](error); } }; - connection.onmessage = function(label, message) { + connection.onmessage = function connection_onmessage(label, message) { if ('unreliable' === label) { handleMessage(addr, message.data); } @@ -7722,13 +7768,13 @@ LibraryManager.library = { Module['webrtc']['onconnect'](peer); } }; - peer.onpending = function(pending) { + peer.onpending = function peer_onpending(pending) { console.log('pending from: ', pending['route'], '; initiated by: ', (pending['incoming']) ? 'remote' : 'local'); }; - peer.onerror = function(error) { + peer.onerror = function peer_onerror(error) { console.error(error); }; - peer.onroute = function(route) { + peer.onroute = function peer_onroute(route) { if (Module['webrtc']['onpeer'] && 'function' === typeof Module['webrtc']['onpeer']) { Module['webrtc']['onpeer'](peer, route); } @@ -7744,7 +7790,7 @@ LibraryManager.library = { console.log("unable to deliver message: ", addr, header[1], message); } } - window.onbeforeunload = function() { + window.onbeforeunload = function window_onbeforeunload() { var ids = Object.keys(Sockets.connections); ids.forEach(function(id) { Sockets.connections[id].close(); @@ -7813,7 +7859,7 @@ LibraryManager.library = { } info.addr = Sockets.localAddr; // 10.0.0.254 info.host = __inet_ntop4_raw(info.addr); - info.close = function() { + info.close = function info_close() { Sockets.portmap[info.port] = undefined; } Sockets.portmap[info.port] = info; @@ -8545,7 +8591,13 @@ LibraryManager.library = { return -1; } var arg = {{{ makeGetValue('varargs', '0', 'i32') }}}; - return FS.ioctl(stream, request, arg); + + try { + return FS.ioctl(stream, request, arg); + } catch (e) { + FS.handleFSError(e); + return -1; + } }, #endif @@ -8724,6 +8776,6 @@ function autoAddDeps(object, name) { // Add aborting stubs for various libc stuff needed by libc++ ['pthread_cond_signal', 'pthread_equal', 'wcstol', 'wcstoll', 'wcstoul', 'wcstoull', 'wcstof', 'wcstod', 'wcstold', 'pthread_join', 'pthread_detach', 'catgets', 'catopen', 'catclose', 'fputwc', '__lockfile', '__unlockfile'].forEach(function(aborter) { - LibraryManager.library[aborter] = function() { throw 'TODO: ' + aborter }; + LibraryManager.library[aborter] = function aborting_stub() { throw 'TODO: ' + aborter }; }); diff --git a/src/library_browser.js b/src/library_browser.js index 59d2945e..39a1c55d 100644 --- a/src/library_browser.js +++ b/src/library_browser.js @@ -4,12 +4,12 @@ mergeInto(LibraryManager.library, { $Browser__deps: ['$PATH'], - $Browser__postset: 'Module["requestFullScreen"] = function(lockPointer, resizeCanvas) { Browser.requestFullScreen(lockPointer, resizeCanvas) };\n' + // exports - 'Module["requestAnimationFrame"] = function(func) { Browser.requestAnimationFrame(func) };\n' + - 'Module["setCanvasSize"] = function(width, height, noUpdates) { Browser.setCanvasSize(width, height, noUpdates) };\n' + - 'Module["pauseMainLoop"] = function() { Browser.mainLoop.pause() };\n' + - 'Module["resumeMainLoop"] = function() { Browser.mainLoop.resume() };\n' + - 'Module["getUserMedia"] = function() { Browser.getUserMedia() }', + $Browser__postset: 'Module["requestFullScreen"] = function Module_requestFullScreen(lockPointer, resizeCanvas) { Browser.requestFullScreen(lockPointer, resizeCanvas) };\n' + // exports + 'Module["requestAnimationFrame"] = function Module_requestAnimationFrame(func) { Browser.requestAnimationFrame(func) };\n' + + 'Module["setCanvasSize"] = function Module_setCanvasSize(width, height, noUpdates) { Browser.setCanvasSize(width, height, noUpdates) };\n' + + 'Module["pauseMainLoop"] = function Module_pauseMainLoop() { Browser.mainLoop.pause() };\n' + + 'Module["resumeMainLoop"] = function Module_resumeMainLoop() { Browser.mainLoop.resume() };\n' + + 'Module["getUserMedia"] = function Module_getUserMedia() { Browser.getUserMedia() }', $Browser: { mainLoop: { scheduler: null, @@ -77,10 +77,10 @@ mergeInto(LibraryManager.library, { // might create some side data structure for use later (like an Image element, etc.). var imagePlugin = {}; - imagePlugin['canHandle'] = function(name) { + imagePlugin['canHandle'] = function imagePlugin_canHandle(name) { return !Module.noImageDecoding && /\.(jpg|jpeg|png|bmp)$/i.test(name); }; - imagePlugin['handle'] = function(byteArray, name, onload, onerror) { + imagePlugin['handle'] = function imagePlugin_handle(byteArray, name, onload, onerror) { var b = null; if (Browser.hasBlobConstructor) { try { @@ -103,7 +103,7 @@ mergeInto(LibraryManager.library, { assert(typeof url == 'string', 'createObjectURL must return a url as a string'); #endif var img = new Image(); - img.onload = function() { + img.onload = function img_onload() { assert(img.complete, 'Image ' + name + ' could not be decoded'); var canvas = document.createElement('canvas'); canvas.width = img.width; @@ -114,7 +114,7 @@ mergeInto(LibraryManager.library, { Browser.URLObject.revokeObjectURL(url); if (onload) onload(byteArray); }; - img.onerror = function(event) { + img.onerror = function img_onerror(event) { console.log('Image ' + url + ' could not be decoded'); if (onerror) onerror(); }; @@ -123,10 +123,10 @@ mergeInto(LibraryManager.library, { Module['preloadPlugins'].push(imagePlugin); var audioPlugin = {}; - audioPlugin['canHandle'] = function(name) { + audioPlugin['canHandle'] = function audioPlugin_canHandle(name) { return !Module.noAudioDecoding && name.substr(-4) in { '.ogg': 1, '.wav': 1, '.mp3': 1 }; }; - audioPlugin['handle'] = function(byteArray, name, onload, onerror) { + audioPlugin['handle'] = function audioPlugin_handle(byteArray, name, onload, onerror) { var done = false; function finish(audio) { if (done) return; @@ -152,7 +152,7 @@ mergeInto(LibraryManager.library, { #endif var audio = new Audio(); audio.addEventListener('canplaythrough', function() { finish(audio) }, false); // use addEventListener due to chromium bug 124926 - audio.onerror = function(event) { + audio.onerror = function audio_onerror(event) { if (done) return; console.log('warning: browser could not fully decode audio ' + name + ', trying slower base64 approach'); function encode64(data) { @@ -268,7 +268,7 @@ mergeInto(LibraryManager.library, { (function(prop) { switch (typeof tempCtx[prop]) { case 'function': { - wrapper[prop] = function() { + wrapper[prop] = function gl_wrapper() { if (GL.debug) { var printArgs = Array.prototype.slice.call(arguments).map(Runtime.prettyPrint); Module.printErr('[gl_f:' + prop + ':' + printArgs + ']'); @@ -359,16 +359,20 @@ mergeInto(LibraryManager.library, { canvas.requestFullScreen(); }, - requestAnimationFrame: function(func) { - if (!window.requestAnimationFrame) { - window.requestAnimationFrame = window['requestAnimationFrame'] || - window['mozRequestAnimationFrame'] || - window['webkitRequestAnimationFrame'] || - window['msRequestAnimationFrame'] || - window['oRequestAnimationFrame'] || - window['setTimeout']; + requestAnimationFrame: function requestAnimationFrame(func) { + if (typeof window === 'undefined') { // Provide fallback to setTimeout if window is undefined (e.g. in Node.js) + setTimeout(func, 1000/60); + } else { + if (!window.requestAnimationFrame) { + window.requestAnimationFrame = window['requestAnimationFrame'] || + window['mozRequestAnimationFrame'] || + window['webkitRequestAnimationFrame'] || + window['msRequestAnimationFrame'] || + window['oRequestAnimationFrame'] || + window['setTimeout']; + } + window.requestAnimationFrame(func); } - window.requestAnimationFrame(func); }, // generic abort-aware wrapper for an async callback @@ -497,7 +501,7 @@ mergeInto(LibraryManager.library, { var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.responseType = 'arraybuffer'; - xhr.onload = function() { + xhr.onload = function xhr_onload() { if (xhr.status == 200 || (xhr.status == 0 && xhr.response)) { // file URLs can return 0 onload(xhr.response); } else { @@ -610,7 +614,7 @@ mergeInto(LibraryManager.library, { http.responseType = 'arraybuffer'; // LOAD - http.onload = function(e) { + http.onload = function http_onload(e) { if (http.status == 200) { FS.createDataFile( _file.substr(0, index), _file.substr(index + 1), new Uint8Array(http.response), true, true); if (onload) Runtime.dynCall('vii', onload, [arg, file]); @@ -620,12 +624,12 @@ mergeInto(LibraryManager.library, { }; // ERROR - http.onerror = function(e) { + http.onerror = function http_onerror(e) { if (onerror) Runtime.dynCall('vii', onerror, [arg, http.status]); }; // PROGRESS - http.onprogress = function(e) { + http.onprogress = function http_onprogress(e) { var percentComplete = (e.position / e.totalSize)*100; if (onprogress) Runtime.dynCall('vii', onprogress, [arg, percentComplete]); }; @@ -705,7 +709,7 @@ mergeInto(LibraryManager.library, { assert(runDependencies === 0, 'async_load_script must be run when no other dependencies are active'); var script = document.createElement('script'); - script.onload = function() { + script.onload = function script_onload() { if (runDependencies > 0) { dependenciesFulfilled = onload; } else { @@ -720,7 +724,7 @@ mergeInto(LibraryManager.library, { emscripten_set_main_loop: function(func, fps, simulateInfiniteLoop) { Module['noExitRuntime'] = true; - Browser.mainLoop.runner = function() { + Browser.mainLoop.runner = function Browser_mainLoop_runner() { if (ABORT) return; if (Browser.mainLoop.queue.length > 0) { var start = Date.now(); @@ -777,11 +781,11 @@ mergeInto(LibraryManager.library, { Browser.mainLoop.scheduler(); } if (fps && fps > 0) { - Browser.mainLoop.scheduler = function() { + Browser.mainLoop.scheduler = function Browser_mainLoop_scheduler() { setTimeout(Browser.mainLoop.runner, 1000/fps); // doing this each time means that on exception, we stop } } else { - Browser.mainLoop.scheduler = function() { + Browser.mainLoop.scheduler = function Browser_mainLoop_scheduler() { Browser.requestAnimationFrame(Browser.mainLoop.runner); } } @@ -870,14 +874,14 @@ mergeInto(LibraryManager.library, { emscripten_get_now: function() { if (!_emscripten_get_now.actual) { if (ENVIRONMENT_IS_NODE) { - _emscripten_get_now.actual = function() { + _emscripten_get_now.actual = function _emscripten_get_now_actual() { var t = process['hrtime'](); return t[0] * 1e3 + t[1] / 1e6; } } else if (typeof dateNow !== 'undefined') { _emscripten_get_now.actual = dateNow; } else if (ENVIRONMENT_IS_WEB && window['performance'] && window['performance']['now']) { - _emscripten_get_now.actual = function() { return window['performance']['now'](); }; + _emscripten_get_now.actual = function _emscripten_get_now_actual() { return window['performance']['now'](); }; } else { _emscripten_get_now.actual = Date.now; } @@ -895,7 +899,7 @@ mergeInto(LibraryManager.library, { buffer: 0, bufferSize: 0 }; - info.worker.onmessage = function(msg) { + info.worker.onmessage = function info_worker_onmessage(msg) { var info = Browser.workers[id]; if (!info) return; // worker was destroyed meanwhile var callbackId = msg.data['callbackId']; diff --git a/src/library_egl.js b/src/library_egl.js index cc702fec..73d5e544 100644 --- a/src/library_egl.js +++ b/src/library_egl.js @@ -9,12 +9,16 @@ var LibraryEGL = { $EGL: { // This variable tracks the success status of the most recently invoked EGL function call. - eglErrorCode: 0x3000 /* EGL_SUCCESS */, + errorCode: 0x3000 /* EGL_SUCCESS */, + defaultDisplayInitialized: false, + currentContext: 0 /* EGL_NO_CONTEXT */, + currentReadSurface: 0 /* EGL_NO_SURFACE */, + currentDrawSurface: 0 /* EGL_NO_SURFACE */, stringCache: {}, setErrorCode: function(code) { - EGL.eglErrorCode = code; + EGL.errorCode = code; }, chooseConfig: function(display, attribList, config, config_size, numConfigs) { @@ -65,6 +69,7 @@ var LibraryEGL = { if (minorVersion) { {{{ makeSetValue('minorVersion', '0', '4', 'i32') }}}; // Advertise EGL Minor version: '4' } + EGL.defaultDisplayInitialized = true; EGL.setErrorCode(0x3000 /* EGL_SUCCESS */); return 1; } @@ -80,18 +85,10 @@ var LibraryEGL = { EGL.setErrorCode(0x3008 /* EGL_BAD_DISPLAY */); return 0; } - // TODO: Tear down EGL here. Currently a no-op since we don't need to actually do anything here for the browser. - EGL.setErrorCode(0x3000 /* EGL_SUCCESS */); - return 1; - }, - -// EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy); - eglTerminate: function(display) { - if (display != 62000 /* Magic ID for Emscripten 'default display' */) { - EGL.setErrorCode(0x3008 /* EGL_BAD_DISPLAY */); - return 0; - } - // TODO: Tear down EGL here. Currently a no-op since we don't need to actually do anything here for the browser. + EGL.currentContext = 0; + EGL.currentReadSurface = 0; + EGL.currentDrawSurface = 0; + EGL.defaultDisplayInitialized = false; EGL.setErrorCode(0x3000 /* EGL_SUCCESS */); return 1; }, @@ -248,6 +245,12 @@ var LibraryEGL = { EGL.setErrorCode(0x300D /* EGL_BAD_SURFACE */); return 1; } + if (EGL.currentReadSurface == surface) { + EGL.currentReadSurface = 0; + } + if (EGL.currentDrawSurface == surface) { + EGL.currentDrawSurface = 0; + } EGL.setErrorCode(0x3000 /* EGL_SUCCESS */); return 1; /* Magic ID for Emscripten 'default surface' */ }, @@ -265,6 +268,7 @@ var LibraryEGL = { EGL.windowID = _glutCreateWindow(); if (EGL.windowID != 0) { EGL.setErrorCode(0x3000 /* EGL_SUCCESS */); + // Note: This function only creates a context, but it shall not make it active. return 62004; // Magic ID for Emscripten EGLContext } else { EGL.setErrorCode(0x3009 /* EGL_BAD_MATCH */); // By the EGL 1.4 spec, an implementation that does not support GLES2 (WebGL in this case), this error code is set. @@ -280,10 +284,17 @@ var LibraryEGL = { EGL.setErrorCode(0x3008 /* EGL_BAD_DISPLAY */); return 0; } + if (context != 62004 /* Magic ID for Emscripten EGLContext */) { + EGL.setErrorCode(0x3006 /* EGL_BAD_CONTEXT */); + return 0; + } _glutDestroyWindow(EGL.windowID); EGL.setErrorCode(0x3000 /* EGL_SUCCESS */); - return 62004; // Magic ID for Emscripten EGLContext + if (EGL.currentContext == context) { + EGL.currentContext = 0; + } + return 1 /* EGL_TRUE */; }, // EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx); @@ -407,7 +418,7 @@ var LibraryEGL = { // EGLAPI EGLint EGLAPIENTRY eglGetError(void); eglGetError: function() { - return EGL.eglErrorCode; + return EGL.errorCode; }, // EGLAPI const char * EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name); @@ -477,21 +488,46 @@ var LibraryEGL = { eglMakeCurrent: function(display, draw, read, context) { if (display != 62000 /* Magic ID for Emscripten 'default display' */) { EGL.setErrorCode(0x3008 /* EGL_BAD_DISPLAY */); - return 0; + return 0 /* EGL_FALSE */; } //\todo An EGL_NOT_INITIALIZED error is generated if EGL is not initialized for dpy. - if (context != 62004 /* Magic ID for Emscripten EGLContext */) { + if (context != 0 && context != 62004 /* Magic ID for Emscripten EGLContext */) { EGL.setErrorCode(0x3006 /* EGL_BAD_CONTEXT */); return 0; } - if (read != 62006 || draw != 62006 /* Magic ID for Emscripten 'default surface' */) { + if ((read != 0 && read != 62006) || (draw != 0 && draw != 62006 /* Magic ID for Emscripten 'default surface' */)) { EGL.setErrorCode(0x300D /* EGL_BAD_SURFACE */); return 0; } + EGL.currentContext = context; + EGL.currentDrawSurface = draw; + EGL.currentReadSurface = read; EGL.setErrorCode(0x3000 /* EGL_SUCCESS */); - return 1; + return 1 /* EGL_TRUE */; + }, + + // EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void); + eglGetCurrentContext: function() { + return EGL.currentContext; }, + // EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw); + eglGetCurrentSurface: function(readdraw) { + if (readdraw == 0x305A /* EGL_READ */) { + return EGL.currentReadSurface; + } else if (readdraw == 0x3059 /* EGL_DRAW */) { + return EGL.currentDrawSurface; + } else { + EGL.setErrorCode(0x300C /* EGL_BAD_PARAMETER */); + return 0 /* EGL_NO_SURFACE */; + } + }, + + // EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void); + eglGetCurrentDisplay: function() { + return EGL.currentContext ? 62000 /* Magic ID for Emscripten 'default display' */ : 0; + }, + // EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface); eglSwapBuffers: function() { EGL.setErrorCode(0x3000 /* EGL_SUCCESS */); diff --git a/src/library_fs.js b/src/library_fs.js index aece2664..5412185f 100644 --- a/src/library_fs.js +++ b/src/library_fs.js @@ -361,9 +361,10 @@ mergeInto(LibraryManager.library, { // SOCKFS is completed. createStream: function(stream, fd_start, fd_end) { if (!FS.FSStream) { - FS.FSStream = {}; + FS.FSStream = function(){}; + FS.FSStream.prototype = {}; // compatibility - Object.defineProperties(FS.FSStream, { + Object.defineProperties(FS.FSStream.prototype, { object: { get: function() { return this.node; }, set: function(val) { this.node = val; } @@ -379,7 +380,16 @@ mergeInto(LibraryManager.library, { } }); } - stream.prototype = FS.FSStream; + if (stream.__proto__) { + // reuse the object + stream.__proto__ = FS.FSStream.prototype; + } else { + var newStream = new FS.FSStream(); + for (var p in stream) { + newStream[p] = stream[p]; + } + stream = newStream; + } var fd = FS.nextfd(fd_start, fd_end); stream.fd = fd; FS.streams[fd] = stream; @@ -439,7 +449,7 @@ mergeInto(LibraryManager.library, { var completed = 0; var total = FS.mounts.length; - var done = function(err) { + function done(err) { if (err) { return callback(err); } @@ -1326,11 +1336,11 @@ mergeInto(LibraryManager.library, { if (typeof XMLHttpRequest !== 'undefined') { if (!ENVIRONMENT_IS_WORKER) throw 'Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc'; // Lazy chunked Uint8Array (implements get and length from Uint8Array). Actual getting is abstracted away for eventual reuse. - var LazyUint8Array = function() { + function LazyUint8Array() { this.lengthKnown = false; this.chunks = []; // Loaded chunks. Index is the chunk number } - LazyUint8Array.prototype.get = function(idx) { + LazyUint8Array.prototype.get = function LazyUint8Array_get(idx) { if (idx > this.length-1 || idx < 0) { return undefined; } @@ -1338,10 +1348,10 @@ mergeInto(LibraryManager.library, { var chunkNum = Math.floor(idx / this.chunkSize); return this.getter(chunkNum)[chunkOffset]; } - LazyUint8Array.prototype.setDataGetter = function(getter) { + LazyUint8Array.prototype.setDataGetter = function LazyUint8Array_setDataGetter(getter) { this.getter = getter; } - LazyUint8Array.prototype.cacheLength = function() { + LazyUint8Array.prototype.cacheLength = function LazyUint8Array_cacheLength() { // Find length var xhr = new XMLHttpRequest(); xhr.open('HEAD', url, false); @@ -1437,7 +1447,7 @@ mergeInto(LibraryManager.library, { var keys = Object.keys(node.stream_ops); keys.forEach(function(key) { var fn = node.stream_ops[key]; - stream_ops[key] = function() { + stream_ops[key] = function forceLoadLazyFile() { if (!FS.forceLoadFile(node)) { throw new FS.ErrnoError(ERRNO_CODES.EIO); } @@ -1445,7 +1455,7 @@ mergeInto(LibraryManager.library, { }; }); // use a custom read function - stream_ops.read = function(stream, buffer, offset, length, position) { + stream_ops.read = function stream_ops_read(stream, buffer, offset, length, position) { if (!FS.forceLoadFile(node)) { throw new FS.ErrnoError(ERRNO_CODES.EIO); } @@ -1539,12 +1549,12 @@ mergeInto(LibraryManager.library, { } catch (e) { return onerror(e); } - openRequest.onupgradeneeded = function() { + openRequest.onupgradeneeded = function openRequest_onupgradeneeded() { console.log('creating db'); var db = openRequest.result; db.createObjectStore(FS.DB_STORE_NAME); }; - openRequest.onsuccess = function() { + openRequest.onsuccess = function openRequest_onsuccess() { var db = openRequest.result; var transaction = db.transaction([FS.DB_STORE_NAME], 'readwrite'); var files = transaction.objectStore(FS.DB_STORE_NAME); @@ -1554,8 +1564,8 @@ mergeInto(LibraryManager.library, { } paths.forEach(function(path) { var putRequest = files.put(FS.analyzePath(path).object.contents, path); - putRequest.onsuccess = function() { ok++; if (ok + fail == total) finish() }; - putRequest.onerror = function() { fail++; if (ok + fail == total) finish() }; + putRequest.onsuccess = function putRequest_onsuccess() { ok++; if (ok + fail == total) finish() }; + putRequest.onerror = function putRequest_onerror() { fail++; if (ok + fail == total) finish() }; }); transaction.onerror = onerror; }; @@ -1573,7 +1583,7 @@ mergeInto(LibraryManager.library, { return onerror(e); } openRequest.onupgradeneeded = onerror; // no database to load from - openRequest.onsuccess = function() { + openRequest.onsuccess = function openRequest_onsuccess() { var db = openRequest.result; try { var transaction = db.transaction([FS.DB_STORE_NAME], 'readonly'); @@ -1588,7 +1598,7 @@ mergeInto(LibraryManager.library, { } paths.forEach(function(path) { var getRequest = files.get(path); - getRequest.onsuccess = function() { + getRequest.onsuccess = function getRequest_onsuccess() { if (FS.analyzePath(path).exists) { FS.unlink(path); } @@ -1596,7 +1606,7 @@ mergeInto(LibraryManager.library, { ok++; if (ok + fail == total) finish(); }; - getRequest.onerror = function() { fail++; if (ok + fail == total) finish() }; + getRequest.onerror = function getRequest_onerror() { fail++; if (ok + fail == total) finish() }; }); transaction.onerror = onerror; }; diff --git a/src/library_gl.js b/src/library_gl.js index 76501111..afd36197 100644 --- a/src/library_gl.js +++ b/src/library_gl.js @@ -11,6 +11,7 @@ var LibraryGL = { #endif counter: 1, // 0 is reserved as 'null' in gl + lastError: 0, buffers: [], programs: [], framebuffers: [], @@ -40,7 +41,11 @@ var LibraryGL = { 8 // GL_DOUBLE ], - uniformTable: {}, // name => uniform ID. the uID must be identical until relinking, cannot create a new uID each call to glGetUniformLocation + programInfos: {}, // Stores additional information needed for each shader program. Each entry is of form: + /* { uniforms: {}, // Maps ints back to the opaque WebGLUniformLocation objects. + maxUniformLength: int, // Cached in order to implement glGetProgramiv(GL_ACTIVE_UNIFORM_MAX_LENGTH) + maxAttributeLength: int // Cached in order to implement glGetProgramiv(GL_ACTIVE_ATTRIBUTE_MAX_LENGTH) + } */ stringCache: {}, @@ -51,6 +56,13 @@ var LibraryGL = { Browser.moduleContextCreatedCallbacks.push(GL.initExtensions); }, + // Records a GL error condition that occurred, stored until user calls glGetError() to fetch it. As per GLES2 spec, only the first error + // is remembered, and subsequent errors are discarded until the user has cleared the stored error by a call to glGetError(). + recordError: function recordError(errorCode) { + if (!GL.lastError) { + GL.lastError = errorCode; + } + }, // Get a new ID for a texture/buffer/etc., while keeping the table dense and fast. Creation is farely rare so it is worth optimizing lookups later. getNewId: function(table) { var ret = GL.counter++; @@ -277,7 +289,7 @@ var LibraryGL = { }, #if FULL_ES2 - calcBufLength: function(size, type, stride, count) { + calcBufLength: function calcBufLength(size, type, stride, count) { if (stride > 0) { return count * stride; // XXXvlad this is not exactly correct I don't think } @@ -287,7 +299,7 @@ var LibraryGL = { usedTempBuffers: [], - preDrawHandleClientVertexAttribBindings: function(count) { + preDrawHandleClientVertexAttribBindings: function preDrawHandleClientVertexAttribBindings(count) { GL.resetBufferBinding = false; var used = GL.usedTempBuffers; @@ -321,7 +333,7 @@ var LibraryGL = { } }, - postDrawHandleClientVertexAttribBindings: function() { + postDrawHandleClientVertexAttribBindings: function postDrawHandleClientVertexAttribBindings() { if (GL.resetBufferBinding) { Module.ctx.bindBuffer(Module.ctx.ARRAY_BUFFER, GL.buffers[GL.currArrayBuffer]); } @@ -455,15 +467,23 @@ var LibraryGL = { GL.validateGLObjectID(GL.programs, program, 'populateUniformTable', 'program'); #endif var p = GL.programs[program]; - GL.uniformTable[program] = {}; - var ptable = GL.uniformTable[program]; - // A program's uniformTable maps the string name of an uniform to an integer location of that uniform. + GL.programInfos[program] = { + uniforms: {}, + maxUniformLength: 0, // This is eagerly computed below, since we already enumerate all uniforms anyway. + maxAttributeLength: -1 // This is lazily computed and cached, computed when/if first asked, "-1" meaning not computed yet. + }; + + var ptable = GL.programInfos[program]; + var utable = ptable.uniforms; + // A program's uniform table maps the string name of an uniform to an integer location of that uniform. // The global GL.uniforms map maps integer locations to WebGLUniformLocations. var numUniforms = Module.ctx.getProgramParameter(p, Module.ctx.ACTIVE_UNIFORMS); for (var i = 0; i < numUniforms; ++i) { var u = Module.ctx.getActiveUniform(p, i); var name = u.name; + ptable.maxUniformLength = Math.max(ptable.maxUniformLength, name.length+1); + // Strip off any trailing array specifier we might have got, e.g. "[0]". if (name.indexOf(']', name.length-1) !== -1) { var ls = name.lastIndexOf('['); @@ -471,11 +491,11 @@ var LibraryGL = { } // Optimize memory usage slightly: If we have an array of uniforms, e.g. 'vec3 colors[3];', then - // only store the string 'colors' in ptable, and 'colors[0]', 'colors[1]' and 'colors[2]' will be parsed as 'colors'+i. + // only store the string 'colors' in utable, and 'colors[0]', 'colors[1]' and 'colors[2]' will be parsed as 'colors'+i. // Note that for the GL.uniforms table, we still need to fetch the all WebGLUniformLocations for all the indices. var loc = Module.ctx.getUniformLocation(p, name); var id = GL.getNewId(GL.uniforms); - ptable[name] = [u.size, id]; + utable[name] = [u.size, id]; GL.uniforms[id] = loc; for (var j = 1; j < u.size; ++j) { @@ -522,7 +542,11 @@ var LibraryGL = { ret = allocate(intArrayFromString('OpenGL ES GLSL 1.00 (WebGL)'), 'i8', ALLOC_NORMAL); break; default: - throw 'Failure: Invalid glGetString value: ' + name_; + GL.recordError(0x0500/*GL_INVALID_ENUM*/); +#if GL_ASSERTIONS + Module.printErr('GL_INVALID_ENUM in glGetString: Unknown parameter ' + name_ + '!'); +#endif + return 0; } GL.stringCache[name_] = ret; return ret; @@ -534,6 +558,7 @@ var LibraryGL = { case 0x8DFA: // GL_SHADER_COMPILER {{{ makeSetValue('p', '0', '1', 'i32') }}}; return; + case 0x8DF8: // GL_SHADER_BINARY_FORMATS case 0x8DF9: // GL_NUM_SHADER_BINARY_FORMATS {{{ makeSetValue('p', '0', '0', 'i32') }}}; return; @@ -553,7 +578,11 @@ var LibraryGL = { {{{ makeSetValue('p', '0', 'result ? 1 : 0', 'i8') }}}; break; case "string": - throw 'Native code calling glGetIntegerv(' + name_ + ') on a name which returns a string!'; + GL.recordError(0x0500/*GL_INVALID_ENUM*/); +#if GL_ASSERTIONS + Module.printErr('GL_INVALID_ENUM in glGetIntegerv: Native code calling glGetIntegerv(' + name_ + ') on a name which returns a string!'); +#endif + return; case "object": if (result === null) { {{{ makeSetValue('p', '0', '0', 'i32') }}}; @@ -575,18 +604,45 @@ var LibraryGL = { } else if (result instanceof WebGLTexture) { {{{ makeSetValue('p', '0', 'result.name | 0', 'i32') }}}; } else { - throw 'Unknown object returned from WebGL getParameter'; + GL.recordError(0x0500/*GL_INVALID_ENUM*/); +#if GL_ASSERTIONS + Module.printErr('GL_INVALID_ENUM in glGetIntegerv: Unknown object returned from WebGL getParameter(' + name_ + ')!'); +#endif + return; } break; - case "undefined": - throw 'Native code calling glGetIntegerv(' + name_ + ') and it returns undefined'; default: - throw 'Why did we hit the default case?'; + GL.recordError(0x0500/*GL_INVALID_ENUM*/); +#if GL_ASSERTIONS + Module.printErr('GL_INVALID_ENUM in glGetIntegerv: Native code calling glGetIntegerv(' + name_ + ') and it returns ' + result + ' of type ' + typeof(result) + '!'); +#endif + return; } }, glGetFloatv__sig: 'vii', glGetFloatv: function(name_, p) { + switch(name_) { + case 0x8DFA: // GL_SHADER_COMPILER + {{{ makeSetValue('p', '0', '1', 'float') }}}; + return; + case 0x8DF8: // GL_SHADER_BINARY_FORMATS + GL.recordError(0x0500/*GL_INVALID_ENUM*/); +#if GL_ASSERTIONS + Module.printErr('GL_INVALID_ENUM in glGetFloatv(GL_SHADER_BINARY_FORMATS): Invalid parameter type!'); +#endif + return; + case 0x8DF9: // GL_NUM_SHADER_BINARY_FORMATS + {{{ makeSetValue('p', '0', '0', 'float') }}}; + return; + case 0x86A2: // GL_NUM_COMPRESSED_TEXTURE_FORMATS + // WebGL doesn't have GL_NUM_COMPRESSED_TEXTURE_FORMATS (it's obsolete since GL_COMPRESSED_TEXTURE_FORMATS returns a JS array that can be queried for length), + // so implement it ourselves to allow C++ GLES2 code get the length. + var formats = Module.ctx.getParameter(0x86A3 /*GL_COMPRESSED_TEXTURE_FORMATS*/); + {{{ makeSetValue('p', '0', 'formats.length', 'float') }}}; + return; + } + var result = Module.ctx.getParameter(name_); switch (typeof(result)) { case "number": @@ -599,7 +655,11 @@ var LibraryGL = { {{{ makeSetValue('p', '0', '0', 'float') }}}; case "object": if (result === null) { - throw 'Native code calling glGetFloatv(' + name_ + ') and it returns null'; + GL.recordError(0x0500/*GL_INVALID_ENUM*/); +#if GL_ASSERTIONS + Module.printErr('GL_INVALID_ENUM in glGetFloatv: Native code calling glGetFloatv(' + name_ + ') and it returns null!'); +#endif + return; } else if (result instanceof Float32Array || result instanceof Uint32Array || result instanceof Int32Array || @@ -618,18 +678,45 @@ var LibraryGL = { } else if (result instanceof WebGLTexture) { {{{ makeSetValue('p', '0', 'result.name | 0', 'float') }}}; } else { - throw 'Unknown object returned from WebGL getParameter'; + GL.recordError(0x0500/*GL_INVALID_ENUM*/); +#if GL_ASSERTIONS + Module.printErr('GL_INVALID_ENUM in glGetFloatv: Native code calling glGetFloatv(' + name_ + ') and it returns ' + result + ' of type ' + typeof(result) + '!'); +#endif + return; } break; - case "undefined": - throw 'Native code calling glGetFloatv(' + name_ + ') and it returns undefined'; default: - throw 'Why did we hit the default case?'; + GL.recordError(0x0500/*GL_INVALID_ENUM*/); +#if GL_ASSERTIONS + Module.printErr('GL_INVALID_ENUM in glGetFloatv: Native code calling glGetFloatv(' + name_ + ') and it returns ' + result + ' of type ' + typeof(result) + '!'); +#endif + return; } }, glGetBooleanv__sig: 'vii', glGetBooleanv: function(name_, p) { + switch(name_) { + case 0x8DFA: // GL_SHADER_COMPILER + {{{ makeSetValue('p', '0', '1', 'i8') }}}; + return; + case 0x8DF8: // GL_SHADER_BINARY_FORMATS + GL.recordError(0x0500/*GL_INVALID_ENUM*/); +#if GL_ASSERTIONS + Module.printErr('GL_INVALID_ENUM in glGetBooleanv(GL_SHADER_BINARY_FORMATS): Invalid parameter type!'); +#endif + return; + case 0x8DF9: // GL_NUM_SHADER_BINARY_FORMATS + {{{ makeSetValue('p', '0', '0', 'i8') }}}; + return; + case 0x86A2: // GL_NUM_COMPRESSED_TEXTURE_FORMATS + // WebGL doesn't have GL_NUM_COMPRESSED_TEXTURE_FORMATS (it's obsolete since GL_COMPRESSED_TEXTURE_FORMATS returns a JS array that can be queried for length), + // so implement it ourselves to allow C++ GLES2 code get the length. + var hasCompressedFormats = Module.ctx.getParameter(0x86A3 /*GL_COMPRESSED_TEXTURE_FORMATS*/).length > 0 ? 1 : 0; + {{{ makeSetValue('p', '0', 'hasCompressedFormats', 'i8') }}}; + return; + } + var result = Module.ctx.getParameter(name_); switch (typeof(result)) { case "number": @@ -639,7 +726,11 @@ var LibraryGL = { {{{ makeSetValue('p', '0', 'result != 0', 'i8') }}}; break; case "string": - throw 'Native code calling glGetBooleanv(' + name_ + ') on a name which returns a string!'; + GL.recordError(0x0500/*GL_INVALID_ENUM*/); +#if GL_ASSERTIONS + Module.printErr('GL_INVALID_ENUM in glGetBooleanv: Native code calling glGetBooleanv(' + name_ + ') on a name which returns a string!'); +#endif + return; case "object": if (result === null) { {{{ makeSetValue('p', '0', '0', 'i8') }}}; @@ -657,13 +748,19 @@ var LibraryGL = { result instanceof WebGLTexture) { {{{ makeSetValue('p', '0', '1', 'i8') }}}; // non-zero ID is always 1! } else { - throw 'Unknown object returned from WebGL getParameter'; + GL.recordError(0x0500/*GL_INVALID_ENUM*/); +#if GL_ASSERTIONS + Module.printErr('GL_INVALID_ENUM in glGetBooleanv: Unknown object returned from WebGL getParameter(' + name_ + ')!'); +#endif + return; } break; - case "undefined": - throw 'Unknown object returned from WebGL getParameter'; default: - throw 'Why did we hit the default case?'; + GL.recordError(0x0500/*GL_INVALID_ENUM*/); +#if GL_ASSERTIONS + Module.printErr('GL_INVALID_ENUM in glGetBooleanv: Native code calling glGetBooleanv(' + name_ + ') and it returns ' + result + ' of type ' + typeof(result) + '!'); +#endif + return; } }, @@ -751,7 +848,12 @@ var LibraryGL = { case 0x1908 /* GL_RGBA */: sizePerPixel = 4; break; - default: throw 'unsupported glReadPixels format'; + default: + GL.recordError(0x0500/*GL_INVALID_ENUM*/); +#if GL_ASSERTIONS + Module.printErr('GL_INVALID_ENUM in glReadPixels: Unsupported format ' + format + '!'); +#endif + return; } var totalSize = width*height*sizePerPixel; Module.ctx.readPixels(x, y, width, height, format, type, HEAPU8.subarray(pixels, pixels + totalSize)); @@ -955,11 +1057,12 @@ var LibraryGL = { name = name.slice(0, ls); } - var ptable = GL.uniformTable[program]; + var ptable = GL.programInfos[program]; if (!ptable) { return -1; } - var uniformInfo = ptable[name]; // returns pair [ dimension_of_uniform_array, uniform_location ] + var utable = ptable.uniforms; + var uniformInfo = utable[name]; // returns pair [ dimension_of_uniform_array, uniform_location ] if (uniformInfo && arrayOffset < uniformInfo[0]) { // Check if user asked for an out-of-bounds element, i.e. for 'vec4 colors[3];' user could ask for 'colors[10]' which should return -1. return uniformInfo[1]+arrayOffset; } else { @@ -1447,6 +1550,47 @@ var LibraryGL = { #endif if (pname == 0x8B84) { // GL_INFO_LOG_LENGTH {{{ makeSetValue('p', '0', 'Module.ctx.getProgramInfoLog(GL.programs[program]).length + 1', 'i32') }}}; + } else if (pname == 0x8B87 /* GL_ACTIVE_UNIFORM_MAX_LENGTH */) { + var ptable = GL.programInfos[program]; + if (ptable) { + {{{ makeSetValue('p', '0', 'ptable.maxUniformLength', 'i32') }}}; + return; + } else if (program < GL.counter) { +#if GL_ASSERTIONS + Module.printErr("A GL object " + program + " that is not a program object was passed to glGetProgramiv!"); +#endif + GL.recordError(0x0502 /* GL_INVALID_OPERATION */); + } else { +#if GL_ASSERTIONS + Module.printErr("A GL object " + program + " that did not come from GL was passed to glGetProgramiv!"); +#endif + GL.recordError(0x0501 /* GL_INVALID_VALUE */); + } + } else if (pname == 0x8B8A /* GL_ACTIVE_ATTRIBUTE_MAX_LENGTH */) { + var ptable = GL.programInfos[program]; + if (ptable) { + if (ptable.maxAttributeLength == -1) { + var program = GL.programs[program]; + var numAttribs = Module.ctx.getProgramParameter(program, Module.ctx.ACTIVE_ATTRIBUTES); + ptable.maxAttributeLength = 0; // Spec says if there are no active attribs, 0 must be returned. + for(var i = 0; i < numAttribs; ++i) { + var activeAttrib = Module.ctx.getActiveAttrib(program, i); + ptable.maxAttributeLength = Math.max(ptable.maxAttributeLength, activeAttrib.name.length+1); + } + } + {{{ makeSetValue('p', '0', 'ptable.maxAttributeLength', 'i32') }}}; + return; + } else if (program < GL.counter) { +#if GL_ASSERTIONS + Module.printErr("A GL object " + program + " that is not a program object was passed to glGetProgramiv!"); +#endif + GL.recordError(0x0502 /* GL_INVALID_OPERATION */); + } else { +#if GL_ASSERTIONS + Module.printErr("A GL object " + program + " that did not come from GL was passed to glGetProgramiv!"); +#endif + GL.recordError(0x0501 /* GL_INVALID_VALUE */); + } } else { {{{ makeSetValue('p', '0', 'Module.ctx.getProgramParameter(GL.programs[program], pname)', 'i32') }}}; } @@ -1474,7 +1618,7 @@ var LibraryGL = { Module.ctx.deleteProgram(program); program.name = 0; GL.programs[program] = null; - GL.uniformTable[program] = null; + GL.programInfos[program] = null; }, glAttachShader__sig: 'vii', @@ -1510,7 +1654,7 @@ var LibraryGL = { GL.validateGLObjectID(GL.programs, program, 'glLinkProgram', 'program'); #endif Module.ctx.linkProgram(GL.programs[program]); - GL.uniformTable[program] = {}; // uniforms no longer keep the same names after linking + GL.programInfos[program] = null; // uniforms no longer keep the same names after linking GL.populateUniformTable(program); }, @@ -1682,7 +1826,7 @@ var LibraryGL = { }; var glEnable = _glEnable; - _glEnable = function(cap) { + _glEnable = function _glEnable(cap) { // Clean up the renderer on any change to the rendering state. The optimization of // skipping renderer setup is aimed at the case of multiple glDraw* right after each other if (GL.immediate.lastRenderer) GL.immediate.lastRenderer.cleanup(); @@ -1704,7 +1848,7 @@ var LibraryGL = { }; var glDisable = _glDisable; - _glDisable = function(cap) { + _glDisable = function _glDisable(cap) { if (GL.immediate.lastRenderer) GL.immediate.lastRenderer.cleanup(); if (cap == 0x0B60 /* GL_FOG */) { GLEmulation.fogEnabled = false; @@ -1722,7 +1866,7 @@ var LibraryGL = { } glDisable(cap); }; - _glIsEnabled = function(cap) { + _glIsEnabled = function _glIsEnabled(cap) { if (cap == 0x0B60 /* GL_FOG */) { return GLEmulation.fogEnabled ? 1 : 0; } else if (!(cap in validCapabilities)) { @@ -1732,7 +1876,7 @@ var LibraryGL = { }; var glGetBooleanv = _glGetBooleanv; - _glGetBooleanv = function(pname, p) { + _glGetBooleanv = function _glGetBooleanv(pname, p) { var attrib = GLEmulation.getAttributeFromCapability(pname); if (attrib !== null) { var result = GL.immediate.enabledClientAttributes[attrib]; @@ -1743,7 +1887,7 @@ var LibraryGL = { }; var glGetIntegerv = _glGetIntegerv; - _glGetIntegerv = function(pname, params) { + _glGetIntegerv = function _glGetIntegerv(pname, params) { switch (pname) { case 0x84E2: pname = Module.ctx.MAX_TEXTURE_IMAGE_UNITS /* fake it */; break; // GL_MAX_TEXTURE_UNITS case 0x8B4A: { // GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB @@ -1793,17 +1937,17 @@ var LibraryGL = { return; } case 0x8088: { // GL_TEXTURE_COORD_ARRAY_SIZE - var attribute = GLImmediate.clientAttributes[GLImmediate.TEXTURE0]; + var attribute = GLImmediate.clientAttributes[GLImmediate.TEXTURE0 + GLImmediate.clientActiveTexture]; {{{ makeSetValue('params', '0', 'attribute ? attribute.size : 0', 'i32') }}}; return; } case 0x8089: { // GL_TEXTURE_COORD_ARRAY_TYPE - var attribute = GLImmediate.clientAttributes[GLImmediate.TEXTURE0]; + var attribute = GLImmediate.clientAttributes[GLImmediate.TEXTURE0 + GLImmediate.clientActiveTexture]; {{{ makeSetValue('params', '0', 'attribute ? attribute.type : 0', 'i32') }}}; return; } case 0x808A: { // GL_TEXTURE_COORD_ARRAY_STRIDE - var attribute = GLImmediate.clientAttributes[GLImmediate.TEXTURE0]; + var attribute = GLImmediate.clientAttributes[GLImmediate.TEXTURE0 + GLImmediate.clientActiveTexture]; {{{ makeSetValue('params', '0', 'attribute ? attribute.stride : 0', 'i32') }}}; return; } @@ -1812,7 +1956,7 @@ var LibraryGL = { }; var glGetString = _glGetString; - _glGetString = function(name_) { + _glGetString = function _glGetString(name_) { if (GL.stringCache[name_]) return GL.stringCache[name_]; switch(name_) { case 0x1F03 /* GL_EXTENSIONS */: // Add various extensions that we can support @@ -1836,7 +1980,7 @@ var LibraryGL = { GL.shaderOriginalSources = {}; #endif var glCreateShader = _glCreateShader; - _glCreateShader = function(shaderType) { + _glCreateShader = function _glCreateShader(shaderType) { var id = glCreateShader(shaderType); GL.shaderInfos[id] = { type: shaderType, @@ -1846,7 +1990,7 @@ var LibraryGL = { }; var glShaderSource = _glShaderSource; - _glShaderSource = function(shader, count, string, length) { + _glShaderSource = function _glShaderSource(shader, count, string, length) { var source = GL.getSource(shader, count, string, length); #if GL_DEBUG console.log("glShaderSource: Input: \n" + source); @@ -1959,7 +2103,7 @@ var LibraryGL = { }; var glCompileShader = _glCompileShader; - _glCompileShader = function(shader) { + _glCompileShader = function _glCompileShader(shader) { Module.ctx.compileShader(GL.shaders[shader]); #if GL_DEBUG if (!Module.ctx.getShaderParameter(GL.shaders[shader], Module.ctx.COMPILE_STATUS)) { @@ -1974,14 +2118,14 @@ var LibraryGL = { GL.programShaders = {}; var glAttachShader = _glAttachShader; - _glAttachShader = function(program, shader) { + _glAttachShader = function _glAttachShader(program, shader) { if (!GL.programShaders[program]) GL.programShaders[program] = []; GL.programShaders[program].push(shader); glAttachShader(program, shader); }; var glDetachShader = _glDetachShader; - _glDetachShader = function(program, shader) { + _glDetachShader = function _glDetachShader(program, shader) { var programShader = GL.programShaders[program]; if (!programShader) { Module.printErr('WARNING: _glDetachShader received invalid program: ' + program); @@ -1993,7 +2137,7 @@ var LibraryGL = { }; var glUseProgram = _glUseProgram; - _glUseProgram = function(program) { + _glUseProgram = function _glUseProgram(program) { #if GL_DEBUG if (GL.debug) { Module.printErr('[using program with shaders]'); @@ -2010,7 +2154,7 @@ var LibraryGL = { } var glDeleteProgram = _glDeleteProgram; - _glDeleteProgram = function(program) { + _glDeleteProgram = function _glDeleteProgram(program) { glDeleteProgram(program); if (program == GL.currProgram) GL.currProgram = 0; }; @@ -2018,12 +2162,12 @@ var LibraryGL = { // If attribute 0 was not bound, bind it to 0 for WebGL performance reasons. Track if 0 is free for that. var zeroUsedPrograms = {}; var glBindAttribLocation = _glBindAttribLocation; - _glBindAttribLocation = function(program, index, name) { + _glBindAttribLocation = function _glBindAttribLocation(program, index, name) { if (index == 0) zeroUsedPrograms[program] = true; glBindAttribLocation(program, index, name); }; var glLinkProgram = _glLinkProgram; - _glLinkProgram = function(program) { + _glLinkProgram = function _glLinkProgram(program) { if (!(program in zeroUsedPrograms)) { Module.ctx.bindAttribLocation(GL.programs[program], 0, 'a_position'); } @@ -2031,7 +2175,7 @@ var LibraryGL = { }; var glBindBuffer = _glBindBuffer; - _glBindBuffer = function(target, buffer) { + _glBindBuffer = function _glBindBuffer(target, buffer) { glBindBuffer(target, buffer); if (target == Module.ctx.ARRAY_BUFFER) { if (GLEmulation.currentVao) { @@ -2046,7 +2190,7 @@ var LibraryGL = { }; var glGetFloatv = _glGetFloatv; - _glGetFloatv = function(pname, params) { + _glGetFloatv = function _glGetFloatv(pname, params) { if (pname == 0x0BA6) { // GL_MODELVIEW_MATRIX HEAPF32.set(GL.immediate.matrix['m'], params >> 2); } else if (pname == 0x0BA7) { // GL_PROJECTION_MATRIX @@ -2069,7 +2213,7 @@ var LibraryGL = { }; var glHint = _glHint; - _glHint = function(target, mode) { + _glHint = function _glHint(target, mode) { if (target == 0x84EF) { // GL_TEXTURE_COMPRESSION_HINT return; } @@ -2077,21 +2221,21 @@ var LibraryGL = { }; var glEnableVertexAttribArray = _glEnableVertexAttribArray; - _glEnableVertexAttribArray = function(index) { + _glEnableVertexAttribArray = function _glEnableVertexAttribArray(index) { glEnableVertexAttribArray(index); GLEmulation.enabledVertexAttribArrays[index] = 1; if (GLEmulation.currentVao) GLEmulation.currentVao.enabledVertexAttribArrays[index] = 1; }; var glDisableVertexAttribArray = _glDisableVertexAttribArray; - _glDisableVertexAttribArray = function(index) { + _glDisableVertexAttribArray = function _glDisableVertexAttribArray(index) { glDisableVertexAttribArray(index); delete GLEmulation.enabledVertexAttribArrays[index]; if (GLEmulation.currentVao) delete GLEmulation.currentVao.enabledVertexAttribArrays[index]; }; var glVertexAttribPointer = _glVertexAttribPointer; - _glVertexAttribPointer = function(index, size, type, normalized, stride, pointer) { + _glVertexAttribPointer = function _glVertexAttribPointer(index, size, type, normalized, stride, pointer) { glVertexAttribPointer(index, size, type, normalized, stride, pointer); if (GLEmulation.currentVao) { // TODO: avoid object creation here? likely not hot though GLEmulation.currentVao.vertexAttribPointers[index] = [index, size, type, normalized, stride, pointer]; @@ -2123,9 +2267,6 @@ var LibraryGL = { glGetShaderPrecisionFormat__sig: 'v', glGetShaderPrecisionFormat: function() { throw 'glGetShaderPrecisionFormat: TODO' }, - glShaderBinary__sig: 'v', - glShaderBinary: function() { throw 'glShaderBinary: TODO' }, - glDeleteObject__sig: 'vi', glDeleteObject: function(id) { if (GL.programs[id]) { @@ -2137,11 +2278,6 @@ var LibraryGL = { } }, - glReleaseShaderCompiler__sig: 'v', - glReleaseShaderCompiler: function() { - // NOP (as allowed by GLES 2.0 spec) - }, - glGetObjectParameteriv__sig: 'viii', glGetObjectParameteriv: function(id, type, result) { if (GL.programs[id]) { @@ -2190,8 +2326,13 @@ var LibraryGL = { case 0x8090: // GL_COLOR_ARRAY_POINTER attribute = GLImmediate.clientAttributes[GLImmediate.COLOR]; break; case 0x8092: // GL_TEXTURE_COORD_ARRAY_POINTER - attribute = GLImmediate.clientAttributes[GLImmediate.TEXTURE0]; break; - default: throw 'TODO: glGetPointerv for ' + name; + attribute = GLImmediate.clientAttributes[GLImmediate.TEXTURE0 + GLImmediate.clientActiveTexture]; break; + default: + GL.recordError(0x0500/*GL_INVALID_ENUM*/); +#if GL_ASSERTIONS + Module.printErr('GL_INVALID_ENUM in glGetPointerv: Unsupported name ' + name + '!'); +#endif + return; } {{{ makeSetValue('p', '0', 'attribute ? attribute.pointer : 0', 'i32') }}}; }, @@ -2212,14 +2353,14 @@ var LibraryGL = { function CNaiveListMap() { var list = []; - this.insert = function(key, val) { + this.insert = function CNaiveListMap_insert(key, val) { if (this.contains(key|0)) return false; list.push([key, val]); return true; }; var __contains_i; - this.contains = function(key) { + this.contains = function CNaiveListMap_contains(key) { for (__contains_i = 0; __contains_i < list.length; ++__contains_i) { if (list[__contains_i][0] === key) return true; } @@ -2227,7 +2368,7 @@ var LibraryGL = { }; var __get_i; - this.get = function(key) { + this.get = function CNaiveListMap_get(key) { for (__get_i = 0; __get_i < list.length; ++__get_i) { if (list[__get_i][0] === key) return list[__get_i][1]; } @@ -2261,7 +2402,7 @@ var LibraryGL = { function CNLNode() { var map = new CNaiveListMap(); - this.child = function(keyFrag) { + this.child = function CNLNode_child(keyFrag) { if (!map.contains(keyFrag|0)) { map.insert(keyFrag|0, new CNLNode()); } @@ -2269,11 +2410,11 @@ var LibraryGL = { }; this.value = undefined; - this.get = function() { + this.get = function CNLNode_get() { return this.value; }; - this.set = function(val) { + this.set = function CNLNode_set(val) { this.value = val; }; } @@ -2281,22 +2422,22 @@ var LibraryGL = { function CKeyView(root) { var cur; - this.reset = function() { + this.reset = function CKeyView_reset() { cur = root; return this; }; this.reset(); - this.next = function(keyFrag) { + this.next = function CKeyView_next(keyFrag) { cur = cur.child(keyFrag); return this; }; - this.get = function() { + this.get = function CKeyView_get() { return cur.get(); }; - this.set = function(val) { + this.set = function CKeyView_set(val) { cur.set(val); }; }; @@ -2304,17 +2445,17 @@ var LibraryGL = { var root; var staticKeyView; - this.createKeyView = function() { + this.createKeyView = function CNLNode_createKeyView() { return new CKeyView(root); } - this.clear = function() { + this.clear = function CNLNode_clear() { root = new CNLNode(); staticKeyView = this.createKeyView(); }; this.clear(); - this.getStaticKeyView = function() { + this.getStaticKeyView = function CNLNode_getStaticKeyView() { staticKeyView.reset(); return staticKeyView; }; @@ -2548,7 +2689,7 @@ var LibraryGL = { GL_SRC_ALPHA ]; - this.traverseState = function(keyView) { + this.traverseState = function CTexEnv_traverseState(keyView) { keyView.next(this.mode); keyView.next(this.colorCombiner); keyView.next(this.alphaCombiner); @@ -2584,7 +2725,7 @@ var LibraryGL = { this.enabled_tex3D = false; this.enabled_texCube = false; - this.traverseState = function(keyView) { + this.traverseState = function CTexUnit_traverseState(keyView) { var texUnitType = this.getTexType(); keyView.next(texUnitType); if (!texUnitType) return; @@ -2593,11 +2734,11 @@ var LibraryGL = { }; // Class impls: - CTexUnit.prototype.enabled = function() { + CTexUnit.prototype.enabled = function CTexUnit_enabled() { return this.getTexType() != 0; } - CTexUnit.prototype.genPassLines = function(passOutputVar, passInputVar, texUnitID) { + CTexUnit.prototype.genPassLines = function CTexUnit_genPassLines(passOutputVar, passInputVar, texUnitID) { if (!this.enabled()) { return ["vec4 " + passOutputVar + " = " + passInputVar + ";"]; } @@ -2605,7 +2746,7 @@ var LibraryGL = { return this.env.genPassLines(passOutputVar, passInputVar, texUnitID); } - CTexUnit.prototype.getTexType = function() { + CTexUnit.prototype.getTexType = function CTexUnit_getTexType() { if (this.enabled_texCube) { return GL_TEXTURE_CUBE_MAP; } else if (this.enabled_tex3D) { @@ -2618,7 +2759,7 @@ var LibraryGL = { return 0; } - CTexEnv.prototype.genPassLines = function(passOutputVar, passInputVar, texUnitID) { + CTexEnv.prototype.genPassLines = function CTexEnv_genPassLines(passOutputVar, passInputVar, texUnitID) { switch (this.mode) { case GL_REPLACE: { /* RGB: @@ -2740,9 +2881,9 @@ var LibraryGL = { return Abort_NoSupport("Unsupported TexEnv mode: 0x" + this.mode.toString(16)); } - CTexEnv.prototype.genCombinerLines = function(isColor, outputVar, - passInputVar, texUnitID, - combiner, srcArr, opArr) + CTexEnv.prototype.genCombinerLines = function CTexEnv_getCombinerLines(isColor, outputVar, + passInputVar, texUnitID, + combiner, srcArr, opArr) { var argsNeeded = null; switch (combiner) { @@ -3598,7 +3739,7 @@ var LibraryGL = { // Replace some functions with immediate-mode aware versions. If there are no client // attributes enabled, and we use webgl-friendly modes (no GL_QUADS), then no need // for emulation - _glDrawArrays = function(mode, first, count) { + _glDrawArrays = function _glDrawArrays(mode, first, count) { if (GL.immediate.totalEnabledClientAttributes == 0 && mode <= 6) { Module.ctx.drawArrays(mode, first, count); return; @@ -3614,7 +3755,7 @@ var LibraryGL = { GL.immediate.mode = -1; }; - _glDrawElements = function(mode, count, type, indices, start, end) { // start, end are given if we come from glDrawRangeElements + _glDrawElements = function _glDrawElements(mode, count, type, indices, start, end) { // start, end are given if we come from glDrawRangeElements if (GL.immediate.totalEnabledClientAttributes == 0 && mode <= 6 && GL.currElementArrayBuffer) { Module.ctx.drawElements(mode, count, type, indices); return; @@ -3654,43 +3795,43 @@ var LibraryGL = { } var glActiveTexture = _glActiveTexture; - _glActiveTexture = function(texture) { + _glActiveTexture = function _glActiveTexture(texture) { GL.immediate.TexEnvJIT.hook_activeTexture(texture); glActiveTexture(texture); }; var glEnable = _glEnable; - _glEnable = function(cap) { + _glEnable = function _glEnable(cap) { GL.immediate.TexEnvJIT.hook_enable(cap); glEnable(cap); }; var glDisable = _glDisable; - _glDisable = function(cap) { + _glDisable = function _glDisable(cap) { GL.immediate.TexEnvJIT.hook_disable(cap); glDisable(cap); }; var glTexEnvf = (typeof(_glTexEnvf) != 'undefined') ? _glTexEnvf : function(){}; - _glTexEnvf = function(target, pname, param) { + _glTexEnvf = function _glTexEnvf(target, pname, param) { GL.immediate.TexEnvJIT.hook_texEnvf(target, pname, param); // Don't call old func, since we are the implementor. //glTexEnvf(target, pname, param); }; var glTexEnvi = (typeof(_glTexEnvi) != 'undefined') ? _glTexEnvi : function(){}; - _glTexEnvi = function(target, pname, param) { + _glTexEnvi = function _glTexEnvi(target, pname, param) { GL.immediate.TexEnvJIT.hook_texEnvi(target, pname, param); // Don't call old func, since we are the implementor. //glTexEnvi(target, pname, param); }; var glTexEnvfv = (typeof(_glTexEnvfv) != 'undefined') ? _glTexEnvfv : function(){}; - _glTexEnvfv = function(target, pname, param) { + _glTexEnvfv = function _glTexEnvfv(target, pname, param) { GL.immediate.TexEnvJIT.hook_texEnvfv(target, pname, param); // Don't call old func, since we are the implementor. //glTexEnvfv(target, pname, param); }; var glGetIntegerv = _glGetIntegerv; - _glGetIntegerv = function(pname, params) { + _glGetIntegerv = function _glGetIntegerv(pname, params) { switch (pname) { case 0x8B8D: { // GL_CURRENT_PROGRAM // Just query directly so we're working with WebGL objects. @@ -4618,6 +4759,30 @@ var LibraryGL = { #endif }, + glShaderBinary__sig: 'v', + glShaderBinary: function() { + GL.recordError(0x0500/*GL_INVALID_ENUM*/); +#if GL_ASSERTIONS + Module.printErr("GL_INVALID_ENUM in glShaderBinary: WebGL does not support binary shader formats! Calls to glShaderBinary always fail."); +#endif + }, + + glReleaseShaderCompiler__sig: 'v', + glReleaseShaderCompiler: function() { + // NOP (as allowed by GLES 2.0 spec) + }, + + glGetError__sig: 'i', + glGetError: function() { + // First return any GL error generated by the emscripten library_gl.js interop layer. + if (GL.lastError) { + var error = GL.lastError; + GL.lastError = 0/*GL_NO_ERROR*/; + return error; + } else { // If there were none, return the GL error from the browser GL context. + return Module.ctx.getError(); + } + }, // signatures of simple pass-through functions, see later glActiveTexture__sig: 'vi', @@ -4651,14 +4816,13 @@ var LibraryGL = { glFlush__sig: 'v', glClearColor__sig: 'viiii', glIsEnabled__sig: 'ii', - glGetError__sig: 'i', glFrontFace__sig: 'vi', glSampleCoverage__sig: 'vi', }; // Simple pass-through functions. Starred ones have return values. [X] ones have X in the C name but not in the JS name -[[0, 'getError* finish flush'], +[[0, 'finish flush'], [1, 'clearDepth clearDepth[f] depthFunc enable disable frontFace cullFace clear lineWidth clearStencil depthMask stencilMask checkFramebufferStatus* generateMipmap activeTexture blendEquation sampleCoverage isEnabled*'], [2, 'blendFunc blendEquationSeparate depthRange depthRange[f] stencilMaskSeparate hint polygonOffset vertexAttrib1f'], [3, 'texParameteri texParameterf vertexAttrib2f stencilFunc stencilOp'], @@ -4733,7 +4897,7 @@ LibraryGL.emscripten_GetProcAddress__deps = [function() { tableImpl += '}\nreturn 0;'; LibraryManager.library.emscripten_procAddressTable = new Function('name', tableImpl); }, 'emscripten_procAddressTable']; -LibraryGL.emscripten_GetProcAddress = function(name) { +LibraryGL.emscripten_GetProcAddress = function _LibraryGL_emscripten_GetProcAddress(name) { name = name.replace('EXT', '').replace('ARB', ''); switch(name) { // misc renamings case 'glCreateProgramObject': name = 'glCreateProgram'; break; diff --git a/src/library_glut.js b/src/library_glut.js index fefe7bd3..ba4d75ab 100644 --- a/src/library_glut.js +++ b/src/library_glut.js @@ -59,6 +59,9 @@ var LibraryGLUT = { getSpecialKey: function(keycode) { var key = null; switch (keycode) { + case 8: key = 120 /* backspace */; break; + case 46: key = 111 /* delete */; break; + case 0x70 /*DOM_VK_F1*/: key = 1 /* GLUT_KEY_F1 */; break; case 0x71 /*DOM_VK_F2*/: key = 2 /* GLUT_KEY_F2 */; break; case 0x72 /*DOM_VK_F3*/: key = 3 /* GLUT_KEY_F3 */; break; @@ -228,14 +231,14 @@ var LibraryGLUT = { if (delta < 0) { button = 4; // wheel down } - + if (GLUT.mouseFunc) { event.preventDefault(); GLUT.saveModifiers(event); Runtime.dynCall('viiii', GLUT.mouseFunc, [button, 0/*GLUT_DOWN*/, Browser.mouseX, Browser.mouseY]); } }, - + // TODO add fullscreen API ala: // http://johndyer.name/native-fullscreen-javascript-api-plus-jquery-plugin/ onFullScreenEventChange: function(event) { @@ -304,7 +307,7 @@ var LibraryGLUT = { // Firefox window.addEventListener("DOMMouseScroll", GLUT.onMouseWheel, true); } - + Browser.resizeListeners.push(function(width, height) { if (GLUT.reshapeFunc) { Runtime.dynCall('vii', GLUT.reshapeFunc, [width, height]); @@ -372,7 +375,7 @@ var LibraryGLUT = { }, glutIdleFunc: function(func) { - var callback = function() { + function callback() { if (GLUT.idleFunc) { Runtime.dynCall('v', GLUT.idleFunc); Browser.safeSetTimeout(callback, 0); diff --git a/src/library_idbfs.js b/src/library_idbfs.js index ab55673f..7f50f17e 100644 --- a/src/library_idbfs.js +++ b/src/library_idbfs.js @@ -58,7 +58,7 @@ mergeInto(LibraryManager.library, { } var completed = 0; - var done = function(err) { + function done(err) { if (err) return callback(err); if (++completed >= total) { return callback(null); @@ -68,7 +68,7 @@ mergeInto(LibraryManager.library, { // create a single transaction to handle and IDB reads / writes we'll need to do var db = src.type === 'remote' ? src.db : dst.db; var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readwrite'); - transaction.onerror = function() { callback(this.error); }; + transaction.onerror = function transaction_onerror() { callback(this.error); }; var store = transaction.objectStore(IDBFS.DB_STORE_NAME); for (var path in create) { @@ -92,8 +92,8 @@ mergeInto(LibraryManager.library, { } else { // save file to IDB var req = store.put(entry, path); - req.onsuccess = function() { done(null); }; - req.onerror = function() { done(this.error); }; + req.onsuccess = function req_onsuccess() { done(null); }; + req.onerror = function req_onerror() { done(this.error); }; } } @@ -117,18 +117,18 @@ mergeInto(LibraryManager.library, { } else { // delete file from IDB var req = store.delete(path); - req.onsuccess = function() { done(null); }; - req.onerror = function() { done(this.error); }; + req.onsuccess = function req_onsuccess() { done(null); }; + req.onerror = function req_onerror() { done(this.error); }; } } }, getLocalSet: function(mount, callback) { var files = {}; - var isRealDir = function(p) { + function isRealDir(p) { return p !== '.' && p !== '..'; }; - var toAbsolute = function(root) { + function toAbsolute(root) { return function(p) { return PATH.join2(root, p); } @@ -177,17 +177,17 @@ mergeInto(LibraryManager.library, { } catch (e) { return onerror(e); } - req.onupgradeneeded = function() { + req.onupgradeneeded = function req_onupgradeneeded() { db = req.result; db.createObjectStore(IDBFS.DB_STORE_NAME); }; - req.onsuccess = function() { + req.onsuccess = function req_onsuccess() { db = req.result; // add to the cache IDBFS.dbs[name] = db; callback(null, db); }; - req.onerror = function() { + req.onerror = function req_onerror() { callback(this.error); }; }, @@ -198,10 +198,10 @@ mergeInto(LibraryManager.library, { if (err) return callback(err); var transaction = db.transaction([IDBFS.DB_STORE_NAME], 'readonly'); - transaction.onerror = function() { callback(this.error); }; + transaction.onerror = function transaction_onerror() { callback(this.error); }; var store = transaction.objectStore(IDBFS.DB_STORE_NAME); - store.openCursor().onsuccess = function(event) { + store.openCursor().onsuccess = function store_openCursor_onsuccess(event) { var cursor = event.target.result; if (!cursor) { return callback(null, { type: 'remote', db: db, files: files }); diff --git a/src/library_memfs.js b/src/library_memfs.js index 9f528108..d3148d8b 100644 --- a/src/library_memfs.js +++ b/src/library_memfs.js @@ -225,9 +225,9 @@ mergeInto(LibraryManager.library, { #if ASSERTIONS assert(buffer.length); #endif - if (canOwn && buffer.buffer === HEAP8.buffer && offset === 0) { - node.contents = buffer; // this is a subarray of the heap, and we can own it - node.contentMode = MEMFS.CONTENT_OWNING; + if (canOwn && offset === 0) { + node.contents = buffer; // this could be a subarray of Emscripten HEAP, or allocated from some other source. + node.contentMode = (buffer.buffer === HEAP8.buffer) ? MEMFS.CONTENT_OWNING : MEMFS.CONTENT_FIXED; } else { node.contents = new Uint8Array(buffer.subarray(offset, offset+length)); node.contentMode = MEMFS.CONTENT_FIXED; diff --git a/src/library_openal.js b/src/library_openal.js index e8a2e223..eb152f62 100644 --- a/src/library_openal.js +++ b/src/library_openal.js @@ -8,13 +8,13 @@ var LibraryOpenAL = { QUEUE_INTERVAL: 25, QUEUE_LOOKAHEAD: 100, - updateSources: function(context) { + updateSources: function updateSources(context) { for (var i = 0; i < context.src.length; i++) { AL.updateSource(context.src[i]); } }, - updateSource: function(src) { + updateSource: function updateSource(src) { #if OPENAL_DEBUG var idx = AL.currentContext.src.indexOf(src); #endif @@ -65,7 +65,7 @@ var LibraryOpenAL = { } }, - setSourceState: function(src, state) { + setSourceState: function setSourceState(src, state) { #if OPENAL_DEBUG var idx = AL.currentContext.src.indexOf(src); #endif @@ -119,7 +119,7 @@ var LibraryOpenAL = { } }, - stopSourceQueue: function(src) { + stopSourceQueue: function stopSourceQueue(src) { for (var i = 0; i < src.queue.length; i++) { var entry = src.queue[i]; if (entry.src) { diff --git a/src/library_sdl.js b/src/library_sdl.js index 04a66351..c46364ff 100644 --- a/src/library_sdl.js +++ b/src/library_sdl.js @@ -75,6 +75,7 @@ var LibrarySDL = { textInput: false, startTime: null, + initFlags: 0, // The flags passed to SDL_Init buttonState: 0, modState: 0, DOMButtons: [0, 0, 0], @@ -639,6 +640,21 @@ var LibrarySDL = { {{{ makeSetValue('ptr', C_STRUCTS.SDL_ResizeEvent.h, 'event.h', 'i32') }}}; break; } + case 'joystick_button_up': case 'joystick_button_down': { + var state = event.type === 'joystick_button_up' ? 0 : 1; + {{{ makeSetValue('ptr', C_STRUCTS.SDL_JoyButtonEvent.type, 'SDL.DOMEventToSDLEvent[event.type]', 'i32') }}}; + {{{ makeSetValue('ptr', C_STRUCTS.SDL_JoyButtonEvent.which, 'event.index', 'i8') }}}; + {{{ makeSetValue('ptr', C_STRUCTS.SDL_JoyButtonEvent.button, 'event.button', 'i8') }}}; + {{{ makeSetValue('ptr', C_STRUCTS.SDL_JoyButtonEvent.state, 'state', 'i8') }}}; + break; + } + case 'joystick_axis_motion': { + {{{ makeSetValue('ptr', C_STRUCTS.SDL_JoyAxisEvent.type, 'SDL.DOMEventToSDLEvent[event.type]', 'i32') }}}; + {{{ makeSetValue('ptr', C_STRUCTS.SDL_JoyAxisEvent.which, 'event.index', 'i8') }}}; + {{{ makeSetValue('ptr', C_STRUCTS.SDL_JoyAxisEvent.axis, 'event.axis', 'i8') }}}; + {{{ makeSetValue('ptr', C_STRUCTS.SDL_JoyAxisEvent.value, 'SDL.joystickAxisValueConversion(event.value)', 'i32') }}}; + break; + } default: throw 'Unhandled SDL event: ' + event.type; } }, @@ -695,7 +711,109 @@ var LibrarySDL = { for (var i = 0; i < num; i++) { console.log(' diagonal ' + i + ':' + [data[i*surfData.width*4 + i*4 + 0], data[i*surfData.width*4 + i*4 + 1], data[i*surfData.width*4 + i*4 + 2], data[i*surfData.width*4 + i*4 + 3]]); } - } + }, + + // Joystick helper methods and state + + joystickEventState: 0, + lastJoystickState: {}, // Map from SDL_Joystick* to their last known state. Required to determine if a change has occurred. + // Maps Joystick names to pointers. Allows us to avoid reallocating memory for + // joystick names each time this function is called. + joystickNamePool: {}, + recordJoystickState: function(joystick, state) { + // Standardize button state. + var buttons = new Array(state.buttons.length); + for (var i = 0; i < state.buttons.length; i++) { + buttons[i] = SDL.getJoystickButtonState(state.buttons[i]); + } + + SDL.lastJoystickState[joystick] = { + buttons: buttons, + axes: state.axes.slice(0), + timestamp: state.timestamp, + index: state.index, + id: state.id + }; + }, + // Retrieves the button state of the given gamepad button. + // Abstracts away implementation differences. + // Returns 'true' if pressed, 'false' otherwise. + getJoystickButtonState: function(button) { + if (typeof button === 'object') { + // Current gamepad API editor's draft (Firefox Nightly) + // https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#idl-def-GamepadButton + return button.pressed; + } else { + // Current gamepad API working draft (Firefox / Chrome Stable) + // http://www.w3.org/TR/2012/WD-gamepad-20120529/#gamepad-interface + return button > 0; + } + }, + // Queries for and inserts controller events into the SDL queue. + queryJoysticks: function() { + for (var joystick in SDL.lastJoystickState) { + var state = SDL.getGamepad(joystick - 1); + var prevState = SDL.lastJoystickState[joystick]; + // Check only if the timestamp has differed. + // NOTE: Timestamp is not available in Firefox. + if (typeof state.timestamp !== 'number' || state.timestamp !== prevState.timestamp) { + var i; + for (i = 0; i < state.buttons.length; i++) { + var buttonState = SDL.getJoystickButtonState(state.buttons[i]); + // NOTE: The previous state already has a boolean representation of + // its button, so no need to standardize its button state here. + if (buttonState !== prevState.buttons[i]) { + // Insert button-press event. + SDL.events.push({ + type: buttonState ? 'joystick_button_down' : 'joystick_button_up', + joystick: joystick, + index: joystick - 1, + button: i + }); + } + } + for (i = 0; i < state.axes.length; i++) { + if (state.axes[i] !== prevState.axes[i]) { + // Insert axes-change event. + SDL.events.push({ + type: 'joystick_axis_motion', + joystick: joystick, + index: joystick - 1, + axis: i, + value: state.axes[i] + }); + } + } + + SDL.recordJoystickState(joystick, state); + } + } + }, + // Converts the double-based browser axis value [-1, 1] into SDL's 16-bit + // value [-32768, 32767] + joystickAxisValueConversion: function(value) { + // Ensures that 0 is 0, 1 is 32767, and -1 is 32768. + return Math.ceil(((value+1) * 32767.5) - 32768); + }, + + getGamepads: function() { + var fcn = navigator.getGamepads || navigator.webkitGamepads || navigator.mozGamepads || navigator.gamepads || navigator.webkitGetGamepads; + if (fcn !== undefined) { + // The function must be applied on the navigator object. + return fcn.apply(navigator); + } else { + return []; + } + }, + + // Helper function: Returns the gamepad if available, or null if not. + getGamepad: function(deviceIndex) { + var gamepads = SDL.getGamepads(); + if (gamepads.length > deviceIndex && deviceIndex >= 0) { + return gamepads[deviceIndex]; + } + return null; + }, }, SDL_Linked_Version: function() { @@ -708,8 +826,10 @@ var LibrarySDL = { return SDL.version; }, - SDL_Init: function(what) { + SDL_Init: function(initFlags) { SDL.startTime = Date.now(); + SDL.initFlags = initFlags; + // capture all key events. we just keep down and up, but also capture press to prevent default actions if (!Module['doNotCaptureKeyboard']) { document.addEventListener("keydown", SDL.receiveEvent); @@ -718,6 +838,15 @@ var LibrarySDL = { window.addEventListener("blur", SDL.receiveEvent); document.addEventListener("visibilitychange", SDL.receiveEvent); } + + if (initFlags & 0x200) { + // SDL_INIT_JOYSTICK + // Firefox will not give us Joystick data unless we register this NOP + // callback. + // https://bugzilla.mozilla.org/show_bug.cgi?id=936104 + addEventListener("gamepadconnected", function() {}); + } + window.addEventListener("unload", SDL.receiveEvent); SDL.keyboardState = _malloc(0x10000); // Our SDL needs 512, but 64K is safe for older SDLs _memset(SDL.keyboardState, 0, 0x10000); @@ -730,6 +859,12 @@ var LibrarySDL = { SDL.DOMEventToSDLEvent['mousemove'] = 0x400 /* SDL_MOUSEMOTION */; SDL.DOMEventToSDLEvent['unload'] = 0x100 /* SDL_QUIT */; SDL.DOMEventToSDLEvent['resize'] = 0x7001 /* SDL_VIDEORESIZE/SDL_EVENT_COMPAT2 */; + // These are not technically DOM events; the HTML gamepad API is poll-based. + // However, we define them here, as the rest of the SDL code assumes that + // all SDL events originate as DOM events. + SDL.DOMEventToSDLEvent['joystick_axis_motion'] = 0x600 /* SDL_JOYAXISMOTION */; + SDL.DOMEventToSDLEvent['joystick_button_down'] = 0x603 /* SDL_JOYBUTTONDOWN */; + SDL.DOMEventToSDLEvent['joystick_button_up'] = 0x604 /* SDL_JOYBUTTONUP */; return 0; // success }, @@ -1189,6 +1324,11 @@ var LibrarySDL = { }, SDL_PollEvent: function(ptr) { + if (SDL.initFlags & 0x200 && SDL.joystickEventState) { + // If SDL_INIT_JOYSTICK was supplied AND the joystick system is configured + // to automatically query for events, query for joystick events. + SDL.queryJoysticks(); + } if (SDL.events.length === 0) return 0; if (ptr) { SDL.makeCEvent(SDL.events.shift(), ptr); @@ -1237,11 +1377,11 @@ var LibrarySDL = { surfData.colors = new Uint8Array(256 * 3); //256 RGB colors } - for (var i = firstColor; i < firstColor + nColors; i++) { - var index = i *3; + for (var i = 0; i < nColors; ++i) { + var index = (firstColor + i) * 3; surfData.colors[index] = {{{ makeGetValue('colors', 'i*4', 'i8', null, true) }}}; - surfData.colors[index +1] = {{{ makeGetValue('colors', 'i*4 +1', 'i8', null, true) }}}; - surfData.colors[index +2] = {{{ makeGetValue('colors', 'i*4 +2', 'i8', null, true) }}}; + surfData.colors[index + 1] = {{{ makeGetValue('colors', 'i*4 + 1', 'i8', null, true) }}}; + surfData.colors[index + 2] = {{{ makeGetValue('colors', 'i*4 + 2', 'i8', null, true) }}}; } return 1; @@ -1301,12 +1441,12 @@ var LibrarySDL = { IMG_Load_RW: function(rwopsID, freeSrc) { try { // stb_image integration support - var cleanup = function() { + function cleanup() { if (rwops && freeSrc) _SDL_FreeRW(rwopsID); }; function addCleanup(func) { var old = cleanup; - cleanup = function() { + cleanup = function added_cleanup() { old(); func(); } @@ -1481,7 +1621,7 @@ var LibrarySDL = { SDL.audio.buffer = _malloc(SDL.audio.bufferSize); // Create a callback function that will be routinely called to ask more audio data from the user application. - SDL.audio.caller = function() { + SDL.audio.caller = function SDL_audio_caller() { if (!SDL.audio) { return; } @@ -1495,7 +1635,7 @@ var LibrarySDL = { SDL.audio.audioOutput['mozSetup'](SDL.audio.channels, SDL.audio.freq); // use string attributes on mozOutput for closure compiler SDL.audio.mozBuffer = new Float32Array(totalSamples); SDL.audio.nextPlayTime = 0; - SDL.audio.pushAudio = function(ptr, size) { + SDL.audio.pushAudio = function SDL_audio_pushAudio(ptr, size) { var mozBuffer = SDL.audio.mozBuffer; // The input audio data for SDL audio is either 8-bit or 16-bit interleaved across channels, output for Mozilla Audio Data API // needs to be Float32 interleaved, so perform a sample conversion. @@ -1862,7 +2002,7 @@ var LibrarySDL = { audio.frequency = info.audio.frequency; // TODO: handle N loops. Behavior matches Mix_PlayMusic audio.loop = loops != 0; - audio['onended'] = function() { // TODO: cache these + audio['onended'] = function SDL_audio_onended() { // TODO: cache these channelInfo.audio = null; if (SDL.channelFinished) { Runtime.getFuncWrapper(SDL.channelFinished, 'vi')(channel); @@ -1889,7 +2029,7 @@ var LibrarySDL = { source.loop = false; source.buffer = context.createBuffer(numChannels, 1, audio.frequency); var jsNode = context.createJavaScriptNode(2048, numChannels, numChannels); - jsNode.onaudioprocess = function(event) { + jsNode.onaudioprocess = function jsNode_onaudioprocess(event) { var buffers = new Array(numChannels); for (var i = 0; i < numChannels; ++i) { buffers[i] = event.outputBuffer.getChannelData(i); @@ -2375,37 +2515,103 @@ var LibrarySDL = { // Joysticks - SDL_NumJoysticks: function() { return 0; }, + SDL_NumJoysticks: function() { + var count = 0; + var gamepads = SDL.getGamepads(); + // The length is not the number of gamepads; check which ones are defined. + for (var i = 0; i < gamepads.length; i++) { + if (gamepads[i] !== undefined) count++; + } + return count; + }, - SDL_JoystickName: function(deviceIndex) { return 0; }, + SDL_JoystickName: function(deviceIndex) { + var gamepad = SDL.getGamepad(deviceIndex); + if (gamepad) { + var name = gamepad.id; + if (SDL.joystickNamePool.hasOwnProperty(name)) { + return SDL.joystickNamePool[name]; + } + return SDL.joystickNamePool[name] = allocate(intArrayFromString(name), 'i8', ALLOC_NORMAL); + } + return 0; + }, - SDL_JoystickOpen: function(deviceIndex) { return 0; }, + SDL_JoystickOpen: function(deviceIndex) { + var gamepad = SDL.getGamepad(deviceIndex); + if (gamepad) { + // Use this as a unique 'pointer' for this joystick. + var joystick = deviceIndex+1; + SDL.recordJoystickState(joystick, gamepad); + return joystick; + } + return 0; + }, - SDL_JoystickOpened: function(deviceIndex) { return 0; }, + SDL_JoystickOpened: function(deviceIndex) { + return SDL.lastJoystickState.hasOwnProperty(deviceIndex+1) ? 1 : 0; + }, - SDL_JoystickIndex: function(joystick) { return 0; }, + SDL_JoystickIndex: function(joystick) { + // joystick pointers are simply the deviceIndex+1. + return joystick - 1; + }, - SDL_JoystickNumAxes: function(joystick) { return 0; }, + SDL_JoystickNumAxes: function(joystick) { + var gamepad = SDL.getGamepad(joystick - 1); + if (gamepad) { + return gamepad.axes.length; + } + return 0; + }, SDL_JoystickNumBalls: function(joystick) { return 0; }, SDL_JoystickNumHats: function(joystick) { return 0; }, - SDL_JoystickNumButtons: function(joystick) { return 0; }, + SDL_JoystickNumButtons: function(joystick) { + var gamepad = SDL.getGamepad(joystick - 1); + if (gamepad) { + return gamepad.buttons.length; + } + return 0; + }, - SDL_JoystickUpdate: function() {}, + SDL_JoystickUpdate: function() { + SDL.queryJoysticks(); + }, - SDL_JoystickEventState: function(state) { return 0; }, + SDL_JoystickEventState: function(state) { + if (state < 0) { + // SDL_QUERY: Return current state. + return SDL.joystickEventState; + } + return SDL.joystickEventState = state; + }, - SDL_JoystickGetAxis: function(joystick, axis) { return 0; }, + SDL_JoystickGetAxis: function(joystick, axis) { + var gamepad = SDL.getGamepad(joystick - 1); + if (gamepad && gamepad.axes.length > axis) { + return SDL.joystickAxisValueConversion(gamepad.axes[axis]); + } + return 0; + }, SDL_JoystickGetHat: function(joystick, hat) { return 0; }, SDL_JoystickGetBall: function(joystick, ball, dxptr, dyptr) { return -1; }, - SDL_JoystickGetButton: function(joystick, button) { return 0; }, + SDL_JoystickGetButton: function(joystick, button) { + var gamepad = SDL.getGamepad(joystick - 1); + if (gamepad && gamepad.buttons.length > button) { + return SDL.getJoystickButtonState(gamepad.buttons[button]) ? 1 : 0; + } + return 0; + }, - SDL_JoystickClose: function(joystick) {}, + SDL_JoystickClose: function(joystick) { + delete SDL.lastJoystickState[joystick]; + }, // Misc diff --git a/src/library_sockfs.js b/src/library_sockfs.js index af29d11b..bc3aa997 100644 --- a/src/library_sockfs.js +++ b/src/library_sockfs.js @@ -138,7 +138,9 @@ mergeInto(LibraryManager.library, { console.log('connect: ' + url); #endif // the node ws library API is slightly different than the browser's - var opts = ENVIRONMENT_IS_NODE ? {} : ['binary']; + var opts = ENVIRONMENT_IS_NODE ? {headers: {'websocket-protocol': ['binary']}} : ['binary']; + // If node we use the ws library. + var WebSocket = ENVIRONMENT_IS_NODE ? require('ws') : window['WebSocket']; ws = new WebSocket(url, opts); ws.binaryType = 'arraybuffer'; } catch (e) { @@ -208,7 +210,7 @@ mergeInto(LibraryManager.library, { } }; - var handleMessage = function(data) { + function handleMessage(data) { assert(typeof data !== 'string' && data.byteLength !== undefined); // must receive an ArrayBuffer data = new Uint8Array(data); // make a typed array view on the array buffer @@ -247,7 +249,7 @@ mergeInto(LibraryManager.library, { }); } else { peer.socket.onopen = handleOpen; - peer.socket.onmessage = function(event) { + peer.socket.onmessage = function peer_socket_onmessage(event) { handleMessage(event.data); }; } @@ -573,4 +575,4 @@ mergeInto(LibraryManager.library, { } } } -});
\ No newline at end of file +}); diff --git a/src/modules.js b/src/modules.js index 854575e0..13cca977 100644 --- a/src/modules.js +++ b/src/modules.js @@ -18,7 +18,7 @@ var LLVM = { PHI_REACHERS: set('branch', 'switch', 'invoke', 'indirectbr'), EXTENDS: set('sext', 'zext'), COMPS: set('icmp', 'fcmp'), - CONVERSIONS: set('inttoptr', 'ptrtoint', 'uitofp', 'sitofp', 'fptosi', 'fptoui'), + CONVERSIONS: set('inttoptr', 'ptrtoint', 'uitofp', 'sitofp', 'fptosi', 'fptoui', 'fpext', 'fptrunc'), INTRINSICS_32: set('_llvm_memcpy_p0i8_p0i8_i64', '_llvm_memmove_p0i8_p0i8_i64', '_llvm_memset_p0i8_i64'), // intrinsics that need args converted to i32 in USE_TYPED_ARRAYS == 2 }; LLVM.GLOBAL_MODIFIERS = set(keys(LLVM.LINKAGES).concat(['constant', 'global', 'hidden'])); @@ -253,13 +253,32 @@ var Functions = { aliases: {}, // in shared modules (MAIN_MODULE or SHARED_MODULE), a list of aliases for functions that have them + getSignatureLetter: function(type) { + switch(type) { + case 'float': return 'f'; + case 'double': return 'd'; + case 'void': return 'v'; + default: return 'i'; + } + }, + + getSignatureType: function(letter) { + switch(letter) { + case 'v': return 'void'; + case 'i': return 'i32'; + case 'f': return 'float'; + case 'd': return 'double'; + default: throw 'what is this sig? ' + sig; + } + }, + getSignature: function(returnType, argTypes, hasVarArgs) { - var sig = returnType == 'void' ? 'v' : (isIntImplemented(returnType) ? 'i' : 'f'); + var sig = Functions.getSignatureLetter(returnType); for (var i = 0; i < argTypes.length; i++) { var type = argTypes[i]; if (!type) break; // varargs if (type in Runtime.FLOAT_TYPES) { - sig += 'f'; + sig += Functions.getSignatureLetter(type); } else { var chunks = getNumIntChunks(type); for (var j = 0; j < chunks; j++) sig += 'i'; @@ -269,15 +288,6 @@ var Functions = { return sig; }, - getSignatureReturnType: function(sig) { - switch(sig[0]) { - case 'v': return 'void'; - case 'i': return 'i32'; - case 'f': return 'double'; - default: throw 'what is this sig? ' + sig; - } - }, - // Mark a function as needing indexing. Python will coordinate them all getIndex: function(ident, sig) { var ret; @@ -350,17 +360,15 @@ var Functions = { if (!wrapped[curr]) { var args = '', arg_coercions = '', call = short + '(', retPre = '', retPost = ''; if (t[0] != 'v') { - if (t[0] == 'i') { - retPre = 'return '; - retPost = '|0'; - } else { - retPre = 'return +'; - } + var temp = asmFFICoercion('X', Functions.getSignatureType(t[0])).split('X'); + retPre = 'return ' + temp[0]; + retPost = temp[1]; } for (var j = 1; j < t.length; j++) { args += (j > 1 ? ',' : '') + 'a' + j; - arg_coercions += 'a' + j + '=' + asmCoercion('a' + j, t[j] != 'i' ? 'float' : 'i32') + ';'; - call += (j > 1 ? ',' : '') + asmCoercion('a' + j, t[j] != 'i' ? 'float' : 'i32'); + var type = Functions.getSignatureType(t[j]); + arg_coercions += 'a' + j + '=' + asmCoercion('a' + j, type) + ';'; + call += (j > 1 ? ',' : '') + asmCoercion('a' + j, type === 'float' ? 'double' : type); // ffi arguments must be doubles if they are floats } call += ')'; if (short == '_setjmp') printErr('WARNING: setjmp used via a function pointer. If this is for libc setjmp (not something of your own with the same name), it will break things'); diff --git a/src/parseTools.js b/src/parseTools.js index ec907a41..08cf9b60 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -629,6 +629,8 @@ function cleanSegment(segment) { var MATHOPS = set(['add', 'sub', 'sdiv', 'udiv', 'mul', 'icmp', 'zext', 'urem', 'srem', 'fadd', 'fsub', 'fmul', 'fdiv', 'fcmp', 'frem', 'uitofp', 'sitofp', 'fpext', 'fptrunc', 'fptoui', 'fptosi', 'trunc', 'sext', 'select', 'shl', 'shr', 'ashl', 'ashr', 'lshr', 'lshl', 'xor', 'or', 'and', 'ptrtoint', 'inttoptr']); +var JS_MATH_BUILTINS = set(['Math_sin', 'Math_cos', 'Math_tan', 'Math_asin', 'Math_acos', 'Math_atan', 'Math_ceil', 'Math_floor', 'Math_exp', 'Math_log', 'Math_sqrt']); + var PARSABLE_LLVM_FUNCTIONS = set('getelementptr', 'bitcast'); mergeInto(PARSABLE_LLVM_FUNCTIONS, MATHOPS); @@ -788,8 +790,8 @@ function splitI64(value, floatConversion) { var high = makeInlineCalculation( asmCoercion('Math_abs(VALUE)', 'double') + ' >= ' + asmEnsureFloat('1', 'double') + ' ? ' + '(VALUE > ' + asmEnsureFloat('0', 'double') + ' ? ' + - asmCoercion('Math_min(' + asmCoercion('Math_floor((VALUE)/' + asmEnsureFloat(4294967296, 'float') + ')', 'double') + ', ' + asmEnsureFloat(4294967295, 'float') + ')', 'i32') + '>>>0' + - ' : ' + asmFloatToInt(asmCoercion('Math_ceil((VALUE - +((' + asmFloatToInt('VALUE') + ')>>>0))/' + asmEnsureFloat(4294967296, 'float') + ')', 'double')) + '>>>0' + + asmCoercion('Math_min(' + asmCoercion('Math_floor((VALUE)/' + asmEnsureFloat(4294967296, 'double') + ')', 'double') + ', ' + asmEnsureFloat(4294967295, 'double') + ')', 'i32') + '>>>0' + + ' : ' + asmFloatToInt(asmCoercion('Math_ceil((VALUE - +((' + asmFloatToInt('VALUE') + ')>>>0))/' + asmEnsureFloat(4294967296, 'double') + ')', 'double')) + '>>>0' + ')' + ' : 0', value, @@ -981,6 +983,12 @@ function parseLLVMString(str) { return ret; } +function expandLLVMString(str) { + return str.replace(/\\../g, function(m) { + return String.fromCharCode(parseInt(m.substr(1), '16')); + }); +} + function getLabelIds(labels) { return labels.map(function(label) { return label.ident }); } @@ -1161,32 +1169,37 @@ function makeVarDef(js) { return js; } +function ensureDot(value) { + value = value.toString(); + // if already dotted, or Infinity or NaN, nothing to do here + // if smaller than 1 and running js opts, we always need to force a coercion (0.001 will turn into 1e-3, which has no .) + if ((value.indexOf('.') >= 0 || /[IN]/.test(value)) && (!RUNNING_JS_OPTS || Math.abs(value) >= 1)) return value; + if (RUNNING_JS_OPTS) return '(+' + value + ')'; // JS optimizer will run, we must do +x, and it will be corrected later + var e = value.indexOf('e'); + if (e < 0) return value + '.0'; + return value.substr(0, e) + '.0' + value.substr(e); +} + function asmEnsureFloat(value, type) { // ensures that a float type has either 5.5 (clearly a float) or +5 (float due to asm coercion) if (!ASM_JS) return value; - // coerce if missing a '.', or if smaller than 1, so could be 1e-5 which has no . - if (type in Runtime.FLOAT_TYPES && isNumber(value) && (value.toString().indexOf('.') < 0 || Math.abs(value) < 1)) { - if (RUNNING_JS_OPTS) { - return '(+' + value + ')'; // JS optimizer will run, we must do +x, and it will be corrected later - } else { - // ensure a . - value = value.toString(); - if (value.indexOf('.') >= 0 || /[IN]/.test(value)) return value; // if already dotted, or Infinity or NaN, nothing to do here - var e = value.indexOf('e'); - if (e < 0) return value + '.0'; - return value.substr(0, e) + '.0' + value.substr(e); - } + if (!isNumber(value)) return value; + if (PRECISE_F32 && type === 'float') { + // normally ok to just emit Math_fround(0), but if the constant is large we may need a .0 (if it can't fit in an int) + if (value == 0) return 'Math_fround(0)'; + value = ensureDot(value); + return 'Math_fround(' + value + ')'; + } + if (type in Runtime.FLOAT_TYPES) { + return ensureDot(value); } else { return value; } } -function asmInitializer(type, impl) { +function asmInitializer(type) { if (type in Runtime.FLOAT_TYPES) { - if (RUNNING_JS_OPTS) { - return '+0'; - } else { - return '.0'; - } + if (PRECISE_F32 && type === 'float') return 'Math_fround(0)'; + return RUNNING_JS_OPTS ? '+0' : '.0'; } else { return '0'; } @@ -1207,7 +1220,11 @@ function asmCoercion(value, type, signedness) { value = '(' + value + ')|0'; } } - return '(+(' + value + '))'; + if (PRECISE_F32 && type === 'float') { + return 'Math_fround(' + value + ')'; + } else { + return '(+(' + value + '))'; + } } } else { return '((' + value + ')|0)'; @@ -2041,7 +2058,7 @@ function makeSignOp(value, type, op, force, ignore) { if (isPointerType(type)) type = 'i32'; // Pointers are treated as 32-bit ints if (!value) return value; var bits, full; - if (type in Runtime.INT_TYPES) { + if (type[0] === 'i') { bits = parseInt(type.substr(1)); full = op + 'Sign(' + value + ', ' + bits + ', ' + Math.floor(ignore || correctSpecificSign()) + ')'; // Always sign/unsign constants at compile time, regardless of CHECK/CORRECT @@ -2050,7 +2067,7 @@ function makeSignOp(value, type, op, force, ignore) { } } if ((ignore || !correctSigns()) && !CHECK_SIGNS && !force) return value; - if (type in Runtime.INT_TYPES) { + if (type[0] === 'i') { // this is an integer, but not a number (or we would have already handled it) // shortcuts if (!CHECK_SIGNS || ignore) { @@ -2123,14 +2140,14 @@ function makeRounding(value, bits, signed, floatConversion) { } } -function makeIsNaN(value) { - if (ASM_JS) return makeInlineCalculation('((VALUE) != (VALUE))', value, 'tempDouble'); +function makeIsNaN(value, type) { + if (ASM_JS) return makeInlineCalculation('((VALUE) != (VALUE))', value, type === 'float' ? 'tempFloat' : 'tempDouble'); return 'isNaN(' + value + ')'; } function makeFloat(value, type) { - if (TO_FLOAT32 && type == 'float') { - return 'Math_toFloat32(' + value + ')'; + if (PRECISE_F32 && type == 'float') { + return 'Math_fround(' + value + ')'; } return value; } @@ -2247,8 +2264,8 @@ function processMathop(item) { case 'lshr': { throw 'shifts should have been legalized!'; } - case 'uitofp': case 'sitofp': return RuntimeGenerator.makeBigInt(low1, high1, op[0] == 'u'); - case 'fptoui': case 'fptosi': return finish(splitI64(idents[0], true)); + case 'uitofp': case 'sitofp': return makeFloat(RuntimeGenerator.makeBigInt(low1, high1, op[0] == 'u'), item.type); + case 'fptoui': case 'fptosi': return finish(splitI64(asmCoercion(idents[0], 'double'), true)); // coerce to double before conversion to i64 case 'icmp': { switch (variant) { case 'uge': return '((' + high1 + '>>>0) >= (' + high2 + '>>>0)) & ((((' + high1 + '>>>0) > (' + high2 + '>>>0)) | ' + @@ -2277,7 +2294,7 @@ function processMathop(item) { case 'trunc': { return '((' + idents[0] + '[0]) & ' + (Math.pow(2, bitsLeft)-1) + ')'; } - case 'select': return idents[0] + ' ? ' + makeCopyI64(idents[1]) + ' : ' + makeCopyI64(idents[2]); + case 'select': return '(' + idents[0] + ' ? ' + makeCopyI64(idents[1]) + ' : ' + makeCopyI64(idents[2]) + ')';; case 'ptrtoint': return makeI64(idents[0], 0); case 'inttoptr': { var m = /\(?\[(\d+),\d+\]\)?/.exec(idents[0]); @@ -2374,6 +2391,9 @@ function processMathop(item) { return 'SIMD.uint32x4BitsToFloat32x4(' + idents[0] + ')'; } } + case 'and': return 'SIMD.and(' + idents[0] + ',' + idents[1] + ')'; + case 'or': return 'SIMD.or(' + idents[0] + ',' + idents[1] + ')'; + case 'xor': return 'SIMD.xor(' + idents[0] + ',' + idents[1] + ')'; default: throw 'vector op todo: ' + dump(item); } } @@ -2429,12 +2449,17 @@ function processMathop(item) { case 'fdiv': return makeFloat(getFastValue(idents[0], '/', idents[1], item.type), item.type); case 'fmul': return makeFloat(getFastValue(idents[0], '*', idents[1], item.type), item.type); case 'frem': return makeFloat(getFastValue(idents[0], '%', idents[1], item.type), item.type); - case 'uitofp': case 'sitofp': return asmCoercion(idents[0], 'double', op[0]); + case 'uitofp': case 'sitofp': return asmCoercion(idents[0], item.type, op[0]); case 'fptoui': case 'fptosi': return makeRounding(idents[0], bitsLeft, op === 'fptosi', true); // TODO: We sometimes generate false instead of 0, etc., in the *cmps. It seemed slightly faster before, but worth rechecking // Note that with typed arrays, these become 0 when written. So that is a potential difference with non-typed array runs. case 'icmp': { + // unsigned coercions can be (X&Y), which is not a valid asm coercion for comparisons + if (ASM_JS && variant[0] === 'u') { + if (idents[0].indexOf('>>>') < 0) idents[0] = '((' + idents[0] + ')>>>0)'; + if (idents[1].indexOf('>>>') < 0) idents[1] = '((' + idents[1] + ')>>>0)'; + } switch (variant) { case 'uge': case 'sge': return idents[0] + '>=' + idents[1]; case 'ule': case 'sle': return idents[0] + '<=' + idents[1]; @@ -2461,8 +2486,8 @@ function processMathop(item) { case 'ult': case 'olt': return idents[0] + '<' + idents[1]; case 'une': case 'one': return idents[0] + '!=' + idents[1]; case 'ueq': case 'oeq': return idents[0] + '==' + idents[1]; - case 'ord': return '!' + makeIsNaN(idents[0]) + '&!' + makeIsNaN(idents[1]); - case 'uno': return makeIsNaN(idents[0]) + '|' + makeIsNaN(idents[1]); + case 'ord': return '!' + makeIsNaN(idents[0], paramTypes[0]) + '&!' + makeIsNaN(idents[1], paramTypes[0]); + case 'uno': return makeIsNaN(idents[0], paramTypes[0]) + '|' + makeIsNaN(idents[1], paramTypes[0]); case 'true': return '1'; default: throw 'Unknown fcmp variant: ' + variant; } @@ -2476,9 +2501,16 @@ function processMathop(item) { } // otherwise, fall through } - case 'fpext': case 'sext': return idents[0]; - case 'fptrunc': return idents[0]; - case 'select': return idents[0] + '?' + asmEnsureFloat(idents[1], item.type) + ':' + asmEnsureFloat(idents[2], item.type); + case 'sext': return idents[0]; + case 'fpext': { + if (PRECISE_F32) return '+(' + idents[0] + ')'; + return idents[0]; + } + case 'fptrunc': { + if (PRECISE_F32) return 'Math_fround(' + idents[0] + ')'; + return idents[0]; + } + case 'select': return '(' + idents[0] + '?' + asmEnsureFloat(idents[1], item.type) + ':' + asmEnsureFloat(idents[2], item.type) + ')'; case 'ptrtoint': case 'inttoptr': { var ret = ''; if (QUANTUM_SIZE == 1) { @@ -2668,3 +2700,14 @@ function ensureVector(ident, base) { return ident == 0 ? base + '32x4.zero()' : ident; } +function ensureValidFFIType(type) { + return type === 'float' ? 'double' : type; // ffi does not tolerate float XXX +} + +// FFI return values must arrive as doubles, and we can force them to floats afterwards +function asmFFICoercion(value, type) { + value = asmCoercion(value, ensureValidFFIType(type)); + if (PRECISE_F32 && type === 'float') value = asmCoercion(value, 'float'); + return value; +} + diff --git a/src/preamble.js b/src/preamble.js index 9e72e7b8..27016c14 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -646,6 +646,10 @@ function demangle(func) { if (func[0] !== '_') return func; if (func[1] !== '_') return func; // C function if (func[2] !== 'Z') return func; + switch (func[3]) { + case 'n': return 'operator new()'; + case 'd': return 'operator delete()'; + } var i = 3; // params, etc. var basicTypes = { @@ -678,7 +682,7 @@ function demangle(func) { var subs = []; function parseNested() { i++; - if (func[i] === 'K') i++; + if (func[i] === 'K') i++; // ignore const var parts = []; while (func[i] !== 'E') { if (func[i] === 'S') { // substitution @@ -689,6 +693,11 @@ function demangle(func) { i = next+1; continue; } + if (func[i] === 'C') { // constructor + parts.push(parts[parts.length-1]); + i += 2; + continue; + } var size = parseInt(func.substr(i)); var pre = size.toString().length; if (!size || !pre) { i--; break; } // counter i++ below us @@ -700,6 +709,7 @@ function demangle(func) { i++; // skip E return parts; } + var first = true; function parse(rawList, limit, allowVoid) { // main parser limit = limit || Infinity; var ret = '', list = []; @@ -707,21 +717,22 @@ function demangle(func) { return '(' + list.join(', ') + ')'; } var name; - if (func[i] !== 'N') { + if (func[i] === 'N') { + // namespaced N-E + name = parseNested().join('::'); + limit--; + if (limit === 0) return rawList ? [name] : name; + } else { // not namespaced - if (func[i] === 'K') i++; + if (func[i] === 'K' || (first && func[i] === 'L')) i++; // ignore const and first 'L' var size = parseInt(func.substr(i)); if (size) { var pre = size.toString().length; name = func.substr(i + pre, size); i += pre + size; } - } else { - // namespaced N-E - name = parseNested().join('::'); - limit--; - if (limit === 0) return rawList ? [name] : name; } + first = false; if (func[i] === 'I') { i++; var iList = parse(true); @@ -1060,7 +1071,7 @@ Module['writeAsciiToMemory'] = writeAsciiToMemory; {{{ reSign }}} #if PRECISE_I32_MUL -if (!Math['imul']) Math['imul'] = function(a, b) { +if (!Math['imul']) Math['imul'] = function imul(a, b) { var ah = a >>> 16; var al = a & 0xffff; var bh = b >>> 16; @@ -1068,17 +1079,22 @@ if (!Math['imul']) Math['imul'] = function(a, b) { return (al*bl + ((ah*bl + al*bh) << 16))|0; }; #else -Math['imul'] = function(a, b) { +Math['imul'] = function imul(a, b) { return (a*b)|0; // fast but imprecise }; #endif Math.imul = Math['imul']; -#if TO_FLOAT32 -if (!Math['toFloat32']) Math['toFloat32'] = function(x) { - return x; -}; -Math.toFloat32 = Math['toFloat32']; +#if PRECISE_F32 +#if PRECISE_F32 == 1 +if (!Math['fround']) { + var froundBuffer = new Float32Array(1); + Math['fround'] = function(x) { froundBuffer[0] = x; return froundBuffer[0] }; +} +#else // 2 +if (!Math['fround']) Math['fround'] = function(x) { return x }; +#endif +Math.fround = Math['fround']; #endif var Math_abs = Math.abs; @@ -1096,7 +1112,7 @@ var Math_ceil = Math.ceil; var Math_floor = Math.floor; var Math_pow = Math.pow; var Math_imul = Math.imul; -var Math_toFloat32 = Math.toFloat32; +var Math_fround = Math.fround; var Math_min = Math.min; // A counter of dependencies for calling run(). If we need to diff --git a/src/proxyClient.js b/src/proxyClient.js index 38ea5771..8f4ad7a6 100644 --- a/src/proxyClient.js +++ b/src/proxyClient.js @@ -5,7 +5,7 @@ Module.ctx = Module.canvas.getContext('2d'); var worker = new Worker('{{{ filename }}}.js'); -worker.onmessage = function(event) { +worker.onmessage = function worker_onmessage(event) { var data = event.data; switch (data.target) { case 'stdout': { diff --git a/src/proxyWorker.js b/src/proxyWorker.js index 29b2528d..5d34b900 100644 --- a/src/proxyWorker.js +++ b/src/proxyWorker.js @@ -2,12 +2,12 @@ function EventListener() { this.listeners = {}; - this.addEventListener = function(event, func) { + this.addEventListener = function addEventListener(event, func) { if (!this.listeners[event]) this.listeners[event] = []; this.listeners[event].push(func); }; - this.fireEvent = function(event) { + this.fireEvent = function fireEvent(event) { event.preventDefault = function(){}; if (event.type in this.listeners) { @@ -22,17 +22,17 @@ var window = this; var windowExtra = new EventListener(); for (var x in windowExtra) window[x] = windowExtra[x]; -window.close = function() { +window.close = function window_close() { postMessage({ target: 'window', method: 'close' }); }; var document = new EventListener(); -document.createElement = function(what) { +document.createElement = function document_createElement(what) { switch(what) { case 'canvas': { var canvas = new EventListener(); - canvas.ensureData = function() { + canvas.ensureData = function canvas_ensureData() { if (!canvas.data || canvas.data.width !== canvas.width || canvas.data.height !== canvas.height) { canvas.data = { width: canvas.width, @@ -42,7 +42,7 @@ document.createElement = function(what) { postMessage({ target: 'canvas', op: 'resize', width: canvas.width, height: canvas.height }); } }; - canvas.getContext = function(type) { + canvas.getContext = function canvas_getContext(type) { assert(type == '2d'); return { getImageData: function(x, y, w, h) { @@ -63,7 +63,7 @@ document.createElement = function(what) { }; }; canvas.boundingClientRect = {}; - canvas.getBoundingClientRect = function() { + canvas.getBoundingClientRect = function canvas_getBoundingClientRect() { return { width: canvas.boundingClientRect.width, height: canvas.boundingClientRect.height, @@ -89,10 +89,10 @@ Module.canvas = document.createElement('canvas'); Module.setStatus = function(){}; -Module.print = function(x) { +Module.print = function Module_print(x) { postMessage({ target: 'stdout', content: x }); }; -Module.printErr = function(x) { +Module.printErr = function Module_printErr(x) { postMessage({ target: 'stderr', content: x }); }; @@ -112,7 +112,7 @@ function messageResender() { } } -onmessage = function(message) { +onmessage = function onmessage(message) { if (!calledMain) { if (!messageBuffer) { messageBuffer = []; diff --git a/src/runtime.js b/src/runtime.js index ca2304da..786ae021 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -82,8 +82,8 @@ var RuntimeGenerator = { // Rounding is inevitable if the number is large. This is a particular problem for small negative numbers // (-1 will be rounded!), so handle negatives separately and carefully makeBigInt: function(low, high, unsigned) { - var unsignedRet = '(' + asmCoercion(makeSignOp(low, 'i32', 'un', 1, 1), 'float') + '+(' + asmCoercion(makeSignOp(high, 'i32', 'un', 1, 1), 'float') + '*' + asmEnsureFloat(4294967296, 'float') + '))'; - var signedRet = '(' + asmCoercion(makeSignOp(low, 'i32', 'un', 1, 1), 'float') + '+(' + asmCoercion(makeSignOp(high, 'i32', 're', 1, 1), 'float') + '*' + asmEnsureFloat(4294967296, 'float') + '))'; + var unsignedRet = '(' + asmCoercion(makeSignOp(low, 'i32', 'un', 1, 1), 'double') + '+(' + asmCoercion(makeSignOp(high, 'i32', 'un', 1, 1), 'double') + '*' + asmEnsureFloat(4294967296, 'double') + '))'; + var signedRet = '(' + asmCoercion(makeSignOp(low, 'i32', 'un', 1, 1), 'double') + '+(' + asmCoercion(makeSignOp(high, 'i32', 're', 1, 1), 'double') + '*' + asmEnsureFloat(4294967296, 'double') + '))'; if (typeof unsigned === 'string') return '(' + unsigned + ' ? ' + unsignedRet + ' : ' + signedRet + ')'; return unsigned ? unsignedRet : signedRet; } @@ -394,7 +394,7 @@ var Runtime = { getFuncWrapper: function(func, sig) { assert(sig); if (!Runtime.funcWrappers[func]) { - Runtime.funcWrappers[func] = function() { + Runtime.funcWrappers[func] = function dynCall_wrapper() { return Runtime.dynCall(sig, func, arguments); }; } @@ -452,7 +452,7 @@ var Runtime = { buffer.length = 0; return ret; } - this.processJSString = function(string) { + this.processJSString = function processJSString(string) { string = unescape(encodeURIComponent(string)); var ret = []; for (var i = 0; i < string.length; i++) { diff --git a/src/settings.js b/src/settings.js index d2b47dc8..bc665973 100644 --- a/src/settings.js +++ b/src/settings.js @@ -115,7 +115,13 @@ var PRECISE_I64_MATH = 1; // If enabled, i64 addition etc. is emulated - which i var PRECISE_I32_MUL = 1; // If enabled, i32 multiplication is done with full precision, which means it is // correct even if the value exceeds the JS double-integer limit of ~52 bits (otherwise, // rounding will occur above that range). -var TO_FLOAT32 = 0; // Use Math.toFloat32 +var PRECISE_F32 = 0; // 0: Use JS numbers for floating-point values. These are 64-bit and do not model C++ + // floats exactly, which are 32-bit. + // 1: Model C++ floats precisely, using Math.fround, polyfilling when necessary. This + // can be slow if the polyfill is used on heavy float32 computation. + // 2: Model C++ floats precisely using Math.fround if available in the JS engine, otherwise + // use an empty polyfill. This will have less of a speed penalty than using the full + // polyfill in cases where engine support is not present. var CLOSURE_ANNOTATIONS = 0; // If set, the generated code will be annotated for the closure // compiler. This potentially lets closure optimize the code better. @@ -384,13 +390,16 @@ var FAKE_X86_FP80 = 1; // Replaces x86_fp80 with double. This loses precision. I var GC_SUPPORT = 1; // Enables GC, see gc.h (this does not add overhead, so it is on by default) -var WARN_ON_UNDEFINED_SYMBOLS = 0; // If set to 1, we will warn on any undefined symbols that - // are not resolved by the library_*.js files. We by default - // do not warn because (1) it is normal in large projects to +var WARN_ON_UNDEFINED_SYMBOLS = 1; // If set to 1, we will warn on any undefined symbols that + // are not resolved by the library_*.js files. Note that + // it is common in large projects to // not implement everything, when you know what is not // going to actually be called (and don't want to mess with - // the existing buildsystem), and (2) functions might be - // implemented later on, say in --pre-js + // the existing buildsystem), and functions might be + // implemented later on, say in --pre-js, so you may + // want to build with -s WARN_ON_UNDEFINED_SYMBOLS=0 to + // disable the warnings if they annoy you. + // See also ERROR_ON_UNDEFINED_SYMBOLS var ERROR_ON_UNDEFINED_SYMBOLS = 0; // If set to 1, we will give a compile-time error on any // undefined symbols (see WARN_ON_UNDEFINED_SYMBOLS). @@ -410,7 +419,8 @@ var HEADLESS = 0; // If 1, will include shim code that tries to 'fake' a browser var BENCHMARK = 0; // If 1, will just time how long main() takes to execute, and not // print out anything at all whatsoever. This is useful for benchmarking. -var ASM_JS = 0; // If 1, generate code in asm.js format. +var ASM_JS = 0; // If 1, generate code in asm.js format. If 2, emits the same code except + // for omitting 'use asm' var PGO = 0; // Enables profile-guided optimization in the form of runtime checks for // which functions are actually called. Emits a list during shutdown that you @@ -421,6 +431,8 @@ var DEAD_FUNCTIONS = []; // Functions on this list are not converted to JS, and // reducing code size. // If a dead function is actually called, you will get a runtime // error. + // This can affect both functions in compiled code, and system + // library functions (e.g., you can use this to kill printf). // TODO: options to lazily load such functions var EXPLICIT_ZEXT = 0; // If 1, generate an explicit conversion of zext i1 to i32, using ?: diff --git a/src/shell.js b/src/shell.js index be23b3c1..b68e16d9 100644 --- a/src/shell.js +++ b/src/shell.js @@ -38,17 +38,17 @@ var ENVIRONMENT_IS_SHELL = !ENVIRONMENT_IS_WEB && !ENVIRONMENT_IS_NODE && !ENVIR if (ENVIRONMENT_IS_NODE) { // Expose functionality in the same simple way that the shells work // Note that we pollute the global namespace here, otherwise we break in node - Module['print'] = function(x) { + Module['print'] = function print(x) { process['stdout'].write(x + '\n'); }; - Module['printErr'] = function(x) { + Module['printErr'] = function printErr(x) { process['stderr'].write(x + '\n'); }; var nodeFS = require('fs'); var nodePath = require('path'); - Module['read'] = function(filename, binary) { + Module['read'] = function read(filename, binary) { filename = nodePath['normalize'](filename); var ret = nodeFS['readFileSync'](filename); // The path is absolute if the normalized version is the same as the resolved. @@ -60,9 +60,9 @@ if (ENVIRONMENT_IS_NODE) { return ret; }; - Module['readBinary'] = function(filename) { return Module['read'](filename, true) }; + Module['readBinary'] = function readBinary(filename) { return Module['read'](filename, true) }; - Module['load'] = function(f) { + Module['load'] = function load(f) { globalEval(read(f)); }; @@ -77,10 +77,10 @@ else if (ENVIRONMENT_IS_SHELL) { if (typeof read != 'undefined') { Module['read'] = read; } else { - Module['read'] = function() { throw 'no read() available (jsc?)' }; + Module['read'] = function read() { throw 'no read() available (jsc?)' }; } - Module['readBinary'] = function(f) { + Module['readBinary'] = function readBinary(f) { return read(f, 'binary'); }; @@ -93,7 +93,7 @@ else if (ENVIRONMENT_IS_SHELL) { this['{{{ EXPORT_NAME }}}'] = Module; } else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) { - Module['read'] = function(url) { + Module['read'] = function read(url) { var xhr = new XMLHttpRequest(); xhr.open('GET', url, false); xhr.send(null); @@ -105,10 +105,10 @@ else if (ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER) { } if (typeof console !== 'undefined') { - Module['print'] = function(x) { + Module['print'] = function print(x) { console.log(x); }; - Module['printErr'] = function(x) { + Module['printErr'] = function printErr(x) { console.log(x); }; } else { @@ -136,7 +136,7 @@ function globalEval(x) { eval.call(null, x); } if (!Module['load'] == 'undefined' && Module['read']) { - Module['load'] = function(f) { + Module['load'] = function load(f) { globalEval(Module['read'](f)); }; } diff --git a/src/struct_info.json b/src/struct_info.json index 5b4726e8..b91d077e 100644 --- a/src/struct_info.json +++ b/src/struct_info.json @@ -290,7 +290,11 @@ "AI_CANONNAME", "AI_PASSIVE", "NI_NAMEREQD", - "EAI_NONAME", + "EAI_NONAME", + "EAI_AGAIN", + "EAI_FAIL", + "EAI_MEMORY", + "EAI_SYSTEM", "EAI_SOCKTYPE", "EAI_BADFLAGS" ], @@ -961,6 +965,21 @@ "x", "y" ], + "SDL_JoyAxisEvent": [ + "type", + "which", + "axis", + "padding1", + "padding2", + "value" + ], + "SDL_JoyButtonEvent": [ + "type", + "which", + "button", + "state", + "padding1" + ], "SDL_ResizeEvent": [ "type", "w", diff --git a/src/utility.js b/src/utility.js index ac821a89..cd27b209 100644 --- a/src/utility.js +++ b/src/utility.js @@ -68,7 +68,7 @@ function warn(a, msg) { a = false; } if (!a) { - printErr('Warning: ' + msg); + printErr('warning: ' + msg); } } @@ -81,7 +81,7 @@ function warnOnce(a, msg) { if (!warnOnce.msgs) warnOnce.msgs = {}; if (msg in warnOnce.msgs) return; warnOnce.msgs[msg] = true; - printErr('Warning: ' + msg); + printErr('warning: ' + msg); } } @@ -89,7 +89,7 @@ var abortExecution = false; function error(msg) { abortExecution = true; - printErr('Error: ' + msg); + printErr('error: ' + msg); } function dedup(items, ident) { @@ -222,7 +222,8 @@ function mergeInto(obj, other) { } function isNumber(x) { - return x == parseFloat(x) || (typeof x == 'string' && x.match(/^-?\d+$/)); + // XXX this does not handle 0xabc123 etc. We should likely also do x == parseInt(x) (which handles that), and remove hack |// handle 0x... as well| + return x == parseFloat(x) || (typeof x == 'string' && x.match(/^-?\d+$/)) || x === 'NaN'; } function isArray(x) { diff --git a/system/include/SDL/SDL_events.h b/system/include/SDL/SDL_events.h index 804ac57e..8be00ceb 100644 --- a/system/include/SDL/SDL_events.h +++ b/system/include/SDL/SDL_events.h @@ -55,6 +55,7 @@ extern "C" { */ typedef enum { + SDL_NOEVENT = 0, SDL_FIRSTEVENT = 0, /**< Unused (do not remove) */ /* Application events */ diff --git a/system/include/emscripten/emscripten.h b/system/include/emscripten/emscripten.h index d30620ec..dd1e01a4 100644 --- a/system/include/emscripten/emscripten.h +++ b/system/include/emscripten/emscripten.h @@ -203,7 +203,7 @@ void emscripten_get_canvas_size(int *width, int *height, int *isFullscreen); * absolute time, and is only meaningful in comparison to * other calls to this function. The unit is ms. */ -float emscripten_get_now(); +double emscripten_get_now(); /* * Simple random number generation in [0, 1), maps to Math.random(). diff --git a/system/include/libcxx/CREDITS.TXT b/system/include/libcxx/CREDITS.TXT index 5e4d14ec..368b526f 100644 --- a/system/include/libcxx/CREDITS.TXT +++ b/system/include/libcxx/CREDITS.TXT @@ -31,7 +31,7 @@ D: FreeBSD and Solaris ports, libcxxrt support, some atomics work. N: Marshall Clow E: mclow.lists@gmail.com E: marshall@idio.com -D: Minor patches and bug fixes. +D: C++14 support, patches and bug fixes. N: Bill Fisher E: william.w.fisher@gmail.com @@ -76,6 +76,10 @@ N: Bjorn Reese E: breese@users.sourceforge.net D: Initial regex prototype +N: Nico Rieck +E: nico.rieck@gmail.com +D: Windows fixes + N: Jonathan Sauer D: Minor patches, mostly related to constexpr @@ -105,6 +109,10 @@ N: Zhang Xiongpang E: zhangxiongpang@gmail.com D: Minor patches and bug fixes. +N: Xing Xue +E: xingxue@ca.ibm.com +D: AIX port + N: Zhihao Yuan E: lichray@gmail.com D: Standard compatibility fixes. diff --git a/system/include/libcxx/__bit_reference b/system/include/libcxx/__bit_reference index 857dd5a4..37b79237 100644 --- a/system/include/libcxx/__bit_reference +++ b/system/include/libcxx/__bit_reference @@ -40,7 +40,7 @@ class __bit_reference __storage_pointer __seg_; __storage_type __mask_; -#if defined(__clang__) +#if defined(__clang__) || defined(__IBMCPP__) || defined(_LIBCPP_MSVC) friend typename _Cp::__self; #else friend class _Cp::__self; @@ -82,7 +82,7 @@ class __bit_reference<_Cp, false> }; template <class _Cp> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT { @@ -92,7 +92,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Cp> __y) _NOEXCEPT } template <class _Cp, class _Dp> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT { @@ -102,7 +102,7 @@ swap(__bit_reference<_Cp> __x, __bit_reference<_Dp> __y) _NOEXCEPT } template <class _Cp> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT { @@ -112,7 +112,7 @@ swap(__bit_reference<_Cp> __x, bool& __y) _NOEXCEPT } template <class _Cp> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void swap(bool& __x, __bit_reference<_Cp> __y) _NOEXCEPT { @@ -130,7 +130,7 @@ class __bit_const_reference __storage_pointer __seg_; __storage_type __mask_; -#if defined(__clang__) +#if defined(__clang__) || defined(__IBMCPP__) || defined(_LIBCPP_MSVC) friend typename _Cp::__self; #else friend class _Cp::__self; @@ -379,7 +379,7 @@ __fill_n_true(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n) } template <class _Cp> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void fill_n(__bit_iterator<_Cp, false> __first, typename _Cp::size_type __n, bool __value_) { @@ -1222,7 +1222,7 @@ private: __bit_iterator(__storage_pointer __s, unsigned __ctz) _NOEXCEPT : __seg_(__s), __ctz_(__ctz) {} -#if defined(__clang__) +#if defined(__clang__) || defined(__IBMCPP__) || defined(_LIBCPP_MSVC) friend typename _Cp::__self; #else friend class _Cp::__self; diff --git a/system/include/libcxx/__config b/system/include/libcxx/__config index b1f0d958..a45b02de 100644 --- a/system/include/libcxx/__config +++ b/system/include/libcxx/__config @@ -79,8 +79,14 @@ # endif # if defined(_MSC_VER) && !defined(__clang__) # define _LIBCPP_MSVC // Using Microsoft Visual C++ compiler +# define _LIBCPP_TOSTRING2(x) #x +# define _LIBCPP_TOSTRING(x) _LIBCPP_TOSTRING2(x) +# define _LIBCPP_WARNING(x) __pragma(message(__FILE__ "(" _LIBCPP_TOSTRING(__LINE__) ") : warning note: " x)) +# endif +# // If mingw not explicitly detected, assume using MS C runtime only. +# ifndef __MINGW32__ +# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library # endif -# define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library #endif // _WIN32 #ifdef __linux__ @@ -132,6 +138,9 @@ # define _LIBCPP_TYPE_VIS #endif +#define _LIBCPP_TYPE_VIS_ONLY +#define _LIBCPP_FUNC_VIS_ONLY + #ifndef _LIBCPP_INLINE_VISIBILITY # ifdef _LIBCPP_MSVC # define _LIBCPP_INLINE_VISIBILITY __forceinline @@ -172,6 +181,14 @@ # endif #endif +#ifndef _LIBCPP_TYPE_VIS_ONLY +# define _LIBCPP_TYPE_VIS_ONLY _LIBCPP_TYPE_VIS +#endif + +#ifndef _LIBCPP_FUNC_VIS_ONLY +# define _LIBCPP_FUNC_VIS_ONLY _LIBCPP_FUNC_VIS +#endif + #ifndef _LIBCPP_INLINE_VISIBILITY #define _LIBCPP_INLINE_VISIBILITY __attribute__ ((__visibility__("hidden"), __always_inline__)) #endif @@ -180,10 +197,6 @@ #define _LIBCPP_EXCEPTION_ABI _LIBCPP_TYPE_VIS #endif -#ifndef _LIBCPP_CANTTHROW -#define _LIBCPP_CANTTHROW __attribute__ ((__nothrow__)) -#endif - #ifndef _LIBCPP_ALWAYS_INLINE #define _LIBCPP_ALWAYS_INLINE __attribute__ ((__visibility__("hidden"), __always_inline__)) #endif @@ -408,6 +421,7 @@ using namespace _LIBCPP_NAMESPACE __attribute__((__strong__)); #define _LIBCPP_HAS_NO_CONSTEXPR #define _LIBCPP_HAS_NO_UNICODE_CHARS #define _LIBCPP_HAS_NO_DELETED_FUNCTIONS +#define _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS #define __alignof__ __alignof #define _LIBCPP_NORETURN __declspec(noreturn) #define _ALIGNAS(x) __declspec(align(x)) @@ -420,10 +434,43 @@ using namespace _LIBCPP_NAMESPACE __attribute__((__strong__)); #define _LIBCPP_END_NAMESPACE_STD } #define _VSTD std +# define _LIBCPP_WEAK +namespace std { +} + +#elif defined(__IBMCPP__) + +#define _ALIGNAS(x) __attribute__((__aligned__(x))) +#define _ALIGNAS_TYPE(x) __attribute__((__aligned__(__alignof(x)))) +#define _ATTRIBUTE(x) __attribute__((x)) +#define _LIBCPP_NORETURN __attribute__((noreturn)) + +#define _NOEXCEPT throw() +#define _NOEXCEPT_(x) + +#define _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#define _LIBCPP_HAS_NO_ADVANCED_SFINAE +#define _LIBCPP_HAS_NO_ALWAYS_INLINE_VARIADICS +#define _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#define _LIBCPP_HAS_NO_NULLPTR +#define _LIBCPP_HAS_NO_UNICODE_CHARS +#define _LIBCPP_HAS_NO_STRONG_ENUMS +#define _LIBCPP_HAS_IS_BASE_OF + +#if defined(_AIX) +#define __MULTILOCALE_API +#endif + +#define _LIBCPP_BEGIN_NAMESPACE_STD namespace std {inline namespace _LIBCPP_NAMESPACE { +#define _LIBCPP_END_NAMESPACE_STD } } +#define _VSTD std::_LIBCPP_NAMESPACE + namespace std { + inline namespace _LIBCPP_NAMESPACE { + } } -#endif // __clang__ || __GNUC__ || _LIBCPP_MSVC +#endif // __clang__ || __GNUC___ || _MSC_VER || __IBMCPP__ #ifdef _LIBCPP_HAS_NO_UNICODE_CHARS typedef unsigned short char16_t; @@ -486,8 +533,23 @@ template <unsigned> struct __static_assert_check {}; #define _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(x) #endif // _LIBCPP_HAS_NO_STRONG_ENUMS +#ifdef _LIBCPP_DEBUG +# if _LIBCPP_DEBUG == 0 +# define _LIBCPP_DEBUG_LEVEL 1 +# elif _LIBCPP_DEBUG == 1 +# define _LIBCPP_DEBUG_LEVEL 2 +# else +# error Supported values for _LIBCPP_DEBUG are 0 and 1 +# endif +# define _LIBCPP_EXTERN_TEMPLATE(...) +#endif + #ifndef _LIBCPP_EXTERN_TEMPLATE -#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; +#define _LIBCPP_EXTERN_TEMPLATE(...) +#endif + +#ifndef _LIBCPP_EXTERN_TEMPLATE2 +#define _LIBCPP_EXTERN_TEMPLATE2(...) extern template __VA_ARGS__; #endif #if defined(__APPLE__) || defined(__FreeBSD__) || defined(_WIN32) || defined(__sun__) || defined(__NetBSD__) @@ -505,16 +567,6 @@ template <unsigned> struct __static_assert_check {}; #define _LIBCPP_WCTYPE_IS_MASK #endif -#ifdef _LIBCPP_DEBUG2 -# if _LIBCPP_DEBUG2 == 0 -# define _LIBCPP_DEBUG_LEVEL 1 -# elif _LIBCPP_DEBUG2 == 1 -# define _LIBCPP_DEBUG_LEVEL 2 -# else -# error Supported values for _LIBCPP_DEBUG2 are 0 and 1 -# endif -#endif - #ifndef _LIBCPP_STD_VER # if __cplusplus <= 201103L # define _LIBCPP_STD_VER 11 @@ -523,10 +575,36 @@ template <unsigned> struct __static_assert_check {}; # endif #endif // _LIBCPP_STD_VER +#if _LIBCPP_STD_VER > 11 +#define _LIBCPP_DEPRECATED [[deprecated]] +#else +#define _LIBCPP_DEPRECATED +#endif + #if _LIBCPP_STD_VER <= 11 #define _LIBCPP_CONSTEXPR_AFTER_CXX11 +#define _LIBCPP_EXPLICIT_AFTER_CXX11 +#define _LIBCPP_DEPRECATED_AFTER_CXX11 #else #define _LIBCPP_CONSTEXPR_AFTER_CXX11 constexpr +#define _LIBCPP_EXPLICIT_AFTER_CXX11 explicit +#define _LIBCPP_DEPRECATED_AFTER_CXX11 [[deprecated]] +#endif + +// Try to find out if RTTI is disabled. +// g++ and cl.exe have RTTI on by default and define a macro when it is. +// g++ only defines the macro in 4.3.2 and onwards. +#if !defined(_LIBCPP_NO_RTTI) +# if defined(__GNUG__) && (__GNUC__ >= 4 && \ + (__GNUC_MINOR__ >= 3 || __GNUC_PATCHLEVEL__ >= 2)) && !defined(__GXX_RTTI) +# define _LIBCPP_NO_RTTI +# elif (defined(_MSC_VER) && !defined(__clang__)) && !defined(_CPPRTTI) +# define _LIBCPP_NO_RTTI +# endif +#endif + +#ifndef _LIBCPP_WEAK +# define _LIBCPP_WEAK __attribute__((__weak__)) #endif #endif // _LIBCPP_CONFIG diff --git a/system/include/libcxx/__debug b/system/include/libcxx/__debug index bac580cf..f1805adc 100644 --- a/system/include/libcxx/__debug +++ b/system/include/libcxx/__debug @@ -11,6 +11,10 @@ #ifndef _LIBCPP_DEBUG_H #define _LIBCPP_DEBUG_H +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + #if _LIBCPP_DEBUG_LEVEL >= 1 # include <cstdlib> @@ -24,10 +28,6 @@ #if _LIBCPP_DEBUG_LEVEL >= 2 -#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) -#pragma GCC system_header -#endif - _LIBCPP_BEGIN_NAMESPACE_STD struct _LIBCPP_TYPE_VIS __c_node; @@ -38,8 +38,15 @@ struct _LIBCPP_TYPE_VIS __i_node __i_node* __next_; __c_node* __c_; +#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS __i_node(const __i_node&) = delete; __i_node& operator=(const __i_node&) = delete; +#else +private: + __i_node(const __i_node&); + __i_node& operator=(const __i_node&); +public: +#endif _LIBCPP_INLINE_VISIBILITY __i_node(void* __i, __i_node* __next, __c_node* __c) : __i_(__i), __next_(__next), __c_(__c) {} @@ -54,8 +61,15 @@ struct _LIBCPP_TYPE_VIS __c_node __i_node** end_; __i_node** cap_; +#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS __c_node(const __c_node&) = delete; __c_node& operator=(const __c_node&) = delete; +#else +private: + __c_node(const __c_node&); + __c_node& operator=(const __c_node&); +public: +#endif _LIBCPP_INLINE_VISIBILITY __c_node(void* __c, __c_node* __next) : __c_(__c), __next_(__next), beg_(nullptr), end_(nullptr), cap_(nullptr) {} @@ -134,8 +148,15 @@ class _LIBCPP_TYPE_VIS __libcpp_db __libcpp_db(); public: +#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS __libcpp_db(const __libcpp_db&) = delete; __libcpp_db& operator=(const __libcpp_db&) = delete; +#else +private: + __libcpp_db(const __libcpp_db&); + __libcpp_db& operator=(const __libcpp_db&); +public: +#endif ~__libcpp_db(); class __db_c_iterator; diff --git a/system/include/libcxx/__functional_03 b/system/include/libcxx/__functional_03 index 662928d8..f9a3d976 100644 --- a/system/include/libcxx/__functional_03 +++ b/system/include/libcxx/__functional_03 @@ -203,7 +203,7 @@ class _LIBCPP_EXCEPTION_ABI bad_function_call { }; -template<class _Fp> class _LIBCPP_TYPE_VIS function; // undefined +template<class _Fp> class _LIBCPP_TYPE_VIS_ONLY function; // undefined namespace __function { @@ -644,7 +644,7 @@ __func<_Fp, _Alloc, _Rp(_A0, _A1, _A2)>::target_type() const } // __function template<class _Rp> -class _LIBCPP_TYPE_VIS function<_Rp()> +class _LIBCPP_TYPE_VIS_ONLY function<_Rp()> { typedef __function::__base<_Rp()> __base; aligned_storage<3*sizeof(void*)>::type __buf_; @@ -928,7 +928,7 @@ function<_Rp()>::target() const #endif // _LIBCPP_NO_RTTI template<class _Rp, class _A0> -class _LIBCPP_TYPE_VIS function<_Rp(_A0)> +class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0)> : public unary_function<_A0, _Rp> { typedef __function::__base<_Rp(_A0)> __base; @@ -1230,7 +1230,7 @@ function<_Rp(_A0)>::target() const #endif // _LIBCPP_NO_RTTI template<class _Rp, class _A0, class _A1> -class _LIBCPP_TYPE_VIS function<_Rp(_A0, _A1)> +class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0, _A1)> : public binary_function<_A0, _A1, _Rp> { typedef __function::__base<_Rp(_A0, _A1)> __base; @@ -1532,7 +1532,7 @@ function<_Rp(_A0, _A1)>::target() const #endif // _LIBCPP_NO_RTTI template<class _Rp, class _A0, class _A1, class _A2> -class _LIBCPP_TYPE_VIS function<_Rp(_A0, _A1, _A2)> +class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_A0, _A1, _A2)> { typedef __function::__base<_Rp(_A0, _A1, _A2)> __base; aligned_storage<3*sizeof(void*)>::type __buf_; @@ -1860,11 +1860,11 @@ swap(function<_Fp>& __x, function<_Fp>& __y) {return __x.swap(__y);} template<class _Tp> struct __is_bind_expression : public false_type {}; -template<class _Tp> struct _LIBCPP_TYPE_VIS is_bind_expression +template<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_bind_expression : public __is_bind_expression<typename remove_cv<_Tp>::type> {}; template<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {}; -template<class _Tp> struct _LIBCPP_TYPE_VIS is_placeholder +template<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_placeholder : public __is_placeholder<typename remove_cv<_Tp>::type> {}; namespace placeholders diff --git a/system/include/libcxx/__functional_base b/system/include/libcxx/__functional_base index 2bc2d2c1..1c337d8b 100644 --- a/system/include/libcxx/__functional_base +++ b/system/include/libcxx/__functional_base @@ -15,6 +15,7 @@ #include <type_traits> #include <typeinfo> #include <exception> +#include <new> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -23,21 +24,21 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _Arg, class _Result> -struct _LIBCPP_TYPE_VIS unary_function +struct _LIBCPP_TYPE_VIS_ONLY unary_function { typedef _Arg argument_type; typedef _Result result_type; }; template <class _Arg1, class _Arg2, class _Result> -struct _LIBCPP_TYPE_VIS binary_function +struct _LIBCPP_TYPE_VIS_ONLY binary_function { typedef _Arg1 first_argument_type; typedef _Arg2 second_argument_type; typedef _Result result_type; }; -template <class _Tp> struct _LIBCPP_TYPE_VIS hash; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY hash; template <class _Tp> struct __has_result_type @@ -55,22 +56,75 @@ template <class _Tp = void> #else template <class _Tp> #endif -struct _LIBCPP_TYPE_VIS less : binary_function<_Tp, _Tp, bool> +struct _LIBCPP_TYPE_VIS_ONLY less : binary_function<_Tp, _Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const {return __x < __y;} }; #if _LIBCPP_STD_VER > 11 template <> -struct _LIBCPP_TYPE_VIS less<void> +struct _LIBCPP_TYPE_VIS_ONLY less<void> { - template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY + template <class _T1, class _T2> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); } + typedef void is_transparent; }; #endif +// addressof + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +_Tp* +addressof(_Tp& __x) _NOEXCEPT +{ + return (_Tp*)&reinterpret_cast<const volatile char&>(__x); +} + +#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF) +// Objective-C++ Automatic Reference Counting uses qualified pointers +// that require special addressof() signatures. When +// _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler +// itself is providing these definitions. Otherwise, we provide them. +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +__strong _Tp* +addressof(__strong _Tp& __x) _NOEXCEPT +{ + return &__x; +} + +#ifdef _LIBCPP_HAS_OBJC_ARC_WEAK +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +__weak _Tp* +addressof(__weak _Tp& __x) _NOEXCEPT +{ + return &__x; +} +#endif + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +__autoreleasing _Tp* +addressof(__autoreleasing _Tp& __x) _NOEXCEPT +{ + return &__x; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +__unsafe_unretained _Tp* +addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT +{ + return &__x; +} +#endif + #ifdef _LIBCPP_HAS_NO_VARIADICS #include <__functional_base_03> @@ -366,7 +420,7 @@ struct __invoke_return }; template <class _Tp> -class _LIBCPP_TYPE_VIS reference_wrapper +class _LIBCPP_TYPE_VIS_ONLY reference_wrapper : public __weak_result_type<_Tp> { public: @@ -377,7 +431,8 @@ private: public: // construct/copy/destroy - _LIBCPP_INLINE_VISIBILITY reference_wrapper(type& __f) _NOEXCEPT : __f_(&__f) {} + _LIBCPP_INLINE_VISIBILITY reference_wrapper(type& __f) _NOEXCEPT + : __f_(_VSTD::addressof(__f)) {} #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES private: reference_wrapper(type&&); public: // = delete; // do not bind to temps #endif @@ -450,6 +505,111 @@ template <class _Tp> void cref(const _Tp&&);// = delete; #endif // _LIBCPP_HAS_NO_VARIADICS +#if _LIBCPP_STD_VER > 11 +template <class _Tp1, class _Tp2 = void> +struct __is_transparent +{ +private: + struct __two {char __lx; char __lxx;}; + template <class _Up> static __two __test(...); + template <class _Up> static char __test(typename _Up::is_transparent* = 0); +public: + static const bool value = sizeof(__test<_Tp1>(0)) == 1; +}; +#endif + +// allocator_arg_t + +struct _LIBCPP_TYPE_VIS_ONLY allocator_arg_t { }; + +#if defined(_LIBCPP_HAS_NO_CONSTEXPR) || defined(_LIBCPP_BUILDING_MEMORY) +extern const allocator_arg_t allocator_arg; +#else +constexpr allocator_arg_t allocator_arg = allocator_arg_t(); +#endif + +// uses_allocator + +template <class _Tp> +struct __has_allocator_type +{ +private: + struct __two {char __lx; char __lxx;}; + template <class _Up> static __two __test(...); + template <class _Up> static char __test(typename _Up::allocator_type* = 0); +public: + static const bool value = sizeof(__test<_Tp>(0)) == 1; +}; + +template <class _Tp, class _Alloc, bool = __has_allocator_type<_Tp>::value> +struct __uses_allocator + : public integral_constant<bool, + is_convertible<_Alloc, typename _Tp::allocator_type>::value> +{ +}; + +template <class _Tp, class _Alloc> +struct __uses_allocator<_Tp, _Alloc, false> + : public false_type +{ +}; + +template <class _Tp, class _Alloc> +struct _LIBCPP_TYPE_VIS_ONLY uses_allocator + : public __uses_allocator<_Tp, _Alloc> +{ +}; + +#ifndef _LIBCPP_HAS_NO_VARIADICS + +// allocator construction + +template <class _Tp, class _Alloc, class ..._Args> +struct __uses_alloc_ctor_imp +{ + static const bool __ua = uses_allocator<_Tp, _Alloc>::value; + static const bool __ic = + is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value; + static const int value = __ua ? 2 - __ic : 0; +}; + +template <class _Tp, class _Alloc, class ..._Args> +struct __uses_alloc_ctor + : integral_constant<int, __uses_alloc_ctor_imp<_Tp, _Alloc, _Args...>::value> + {}; + +template <class _Tp, class _Allocator, class... _Args> +inline _LIBCPP_INLINE_VISIBILITY +void __user_alloc_construct_impl (integral_constant<int, 0>, _Tp *__storage, const _Allocator &, _Args &&... __args ) +{ + new (__storage) _Tp (_VSTD::forward<_Args>(__args)...); +} + +template <class _Tp, class _Allocator, class... _Args> +inline _LIBCPP_INLINE_VISIBILITY +void __user_alloc_construct_impl (integral_constant<int, 1>, _Tp *__storage, const _Allocator &__a, _Args &&... __args ) +{ + new (__storage) _Tp (allocator_arg, __a, _VSTD::forward<_Args>(__args)...); +} + +template <class _Tp, class _Allocator, class... _Args> +inline _LIBCPP_INLINE_VISIBILITY +void __user_alloc_construct_impl (integral_constant<int, 2>, _Tp *__storage, const _Allocator &__a, _Args &&... __args ) +{ + new (__storage) _Tp (_VSTD::forward<_Args>(__args)..., __a); +} + +template <class _Tp, class _Allocator, class... _Args> +inline _LIBCPP_INLINE_VISIBILITY +void __user_alloc_construct (_Tp *__storage, const _Allocator &__a, _Args &&... __args) +{ + __user_alloc_construct_impl( + __uses_alloc_ctor<_Tp, _Allocator>(), + __storage, __a, _VSTD::forward<_Args>(__args)... + ); +} +#endif // _LIBCPP_HAS_NO_VARIADICS + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_FUNCTIONAL_BASE diff --git a/system/include/libcxx/__functional_base_03 b/system/include/libcxx/__functional_base_03 index 11165a96..296dd8db 100644 --- a/system/include/libcxx/__functional_base_03 +++ b/system/include/libcxx/__functional_base_03 @@ -996,7 +996,7 @@ struct __invoke_return2 }; template <class _Tp> -class _LIBCPP_TYPE_VIS reference_wrapper +class _LIBCPP_TYPE_VIS_ONLY reference_wrapper : public __weak_result_type<_Tp> { public: diff --git a/system/include/libcxx/__hash_table b/system/include/libcxx/__hash_table index 6157fcd9..4c4feb03 100644 --- a/system/include/libcxx/__hash_table +++ b/system/include/libcxx/__hash_table @@ -20,7 +20,7 @@ #include <__undef_min_max> -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG # include <__debug> #else # define _LIBCPP_ASSERT(x, m) ((void)0) @@ -85,14 +85,14 @@ __next_pow2(size_t __n) } template <class _Tp, class _Hash, class _Equal, class _Alloc> class __hash_table; -template <class _ConstNodePtr> class _LIBCPP_TYPE_VIS __hash_const_iterator; -template <class _HashIterator> class _LIBCPP_TYPE_VIS __hash_map_iterator; -template <class _HashIterator> class _LIBCPP_TYPE_VIS __hash_map_const_iterator; +template <class _ConstNodePtr> class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator; +template <class _HashIterator> class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator; +template <class _HashIterator> class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator; template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> - class _LIBCPP_TYPE_VIS unordered_map; + class _LIBCPP_TYPE_VIS_ONLY unordered_map; template <class _NodePtr> -class _LIBCPP_TYPE_VIS __hash_iterator +class _LIBCPP_TYPE_VIS_ONLY __hash_iterator { typedef _NodePtr __node_pointer; @@ -212,14 +212,14 @@ private: #endif template <class, class, class, class> friend class __hash_table; - template <class> friend class _LIBCPP_TYPE_VIS __hash_const_iterator; - template <class> friend class _LIBCPP_TYPE_VIS __hash_map_iterator; - template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS unordered_map; - template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS unordered_multimap; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator; + template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_map; + template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap; }; template <class _ConstNodePtr> -class _LIBCPP_TYPE_VIS __hash_const_iterator +class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator { typedef _ConstNodePtr __node_pointer; @@ -359,15 +359,15 @@ private: #endif template <class, class, class, class> friend class __hash_table; - template <class> friend class _LIBCPP_TYPE_VIS __hash_map_const_iterator; - template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS unordered_map; - template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS unordered_multimap; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator; + template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_map; + template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap; }; -template <class _ConstNodePtr> class _LIBCPP_TYPE_VIS __hash_const_local_iterator; +template <class _ConstNodePtr> class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator; template <class _NodePtr> -class _LIBCPP_TYPE_VIS __hash_local_iterator +class _LIBCPP_TYPE_VIS_ONLY __hash_local_iterator { typedef _NodePtr __node_pointer; @@ -503,12 +503,12 @@ private: } #endif template <class, class, class, class> friend class __hash_table; - template <class> friend class _LIBCPP_TYPE_VIS __hash_const_local_iterator; - template <class> friend class _LIBCPP_TYPE_VIS __hash_map_iterator; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator; }; template <class _ConstNodePtr> -class _LIBCPP_TYPE_VIS __hash_const_local_iterator +class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator { typedef _ConstNodePtr __node_pointer; @@ -668,7 +668,7 @@ private: } #endif template <class, class, class, class> friend class __hash_table; - template <class> friend class _LIBCPP_TYPE_VIS __hash_map_const_iterator; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator; }; template <class _Alloc> @@ -1160,8 +1160,8 @@ private: void __deallocate(__node_pointer __np) _NOEXCEPT; __node_pointer __detach() _NOEXCEPT; - template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS unordered_map; - template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS unordered_multimap; + template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_map; + template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap; }; template <class _Tp, class _Hash, class _Equal, class _Alloc> @@ -2101,7 +2101,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(value_type&& __v, __h.get_deleter().__value_constructed = true; __h->__hash_ = __hash; __h->__next_ = nullptr; - return _VSTD::move(__h); + return __h; } #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -2116,7 +2116,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(const value_type& __v __h.get_deleter().__value_constructed = true; __h->__hash_ = hash_function()(__h->__value_); __h->__next_ = nullptr; - return _VSTD::move(__h); + return _VSTD::move(__h); // explicitly moved for C++03 } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -2132,7 +2132,7 @@ __hash_table<_Tp, _Hash, _Equal, _Alloc>::__construct_node(const value_type& __v __h.get_deleter().__value_constructed = true; __h->__hash_ = __hash; __h->__next_ = nullptr; - return _VSTD::move(__h); + return _VSTD::move(__h); // explicitly moved for C++03 } template <class _Tp, class _Hash, class _Equal, class _Alloc> diff --git a/system/include/libcxx/__locale b/system/include/libcxx/__locale index 5ae8fa59..6d75162a 100644 --- a/system/include/libcxx/__locale +++ b/system/include/libcxx/__locale @@ -19,11 +19,13 @@ #include <cstdint> #include <cctype> #include <locale.h> -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) # include <support/win32/locale_win32.h> -#elif (defined(__GLIBC__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)) || defined(__EMSCRIPTEN__) +#elif _AIX +# include <support/ibm/xlocale.h> +#elif (defined(__GLIBC__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__sun__)) || defined(__EMSCRIPTEN__) || defined(__IBMCPP__) # include <xlocale.h> -#endif // _WIN32 || __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ +#endif // _WIN32 || __GLIBC__ || __APPLE__ || __FreeBSD__ || __sun__ || __EMSCRIPTEN__ || __IBMCPP__ #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header @@ -175,7 +177,7 @@ use_facet(const locale& __l) // template <class _CharT> class collate; template <class _CharT> -class _LIBCPP_TYPE_VIS collate +class _LIBCPP_TYPE_VIS_ONLY collate : public locale::facet { public: @@ -254,12 +256,12 @@ collate<_CharT>::do_hash(const char_type* __lo, const char_type* __hi) const return static_cast<long>(__h); } -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS collate<char>) -_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS collate<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS collate<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS collate<wchar_t>) // template <class CharT> class collate_byname; -template <class _CharT> class _LIBCPP_TYPE_VIS collate_byname; +template <class _CharT> class _LIBCPP_TYPE_VIS_ONLY collate_byname; template <> class _LIBCPP_TYPE_VIS collate_byname<char> @@ -361,7 +363,7 @@ public: # else static const mask blank = _CTYPE_B; # endif -#elif defined(__sun__) +#elif defined(__sun__) || defined(_AIX) typedef unsigned int mask; static const mask space = _ISSPACE; static const mask print = _ISPRINT; @@ -392,7 +394,7 @@ public: _LIBCPP_ALWAYS_INLINE ctype_base() {} }; -template <class _CharT> class _LIBCPP_TYPE_VIS ctype; +template <class _CharT> class _LIBCPP_TYPE_VIS_ONLY ctype; template <> class _LIBCPP_TYPE_VIS ctype<wchar_t> @@ -510,7 +512,7 @@ public: _LIBCPP_ALWAYS_INLINE bool is(mask __m, char_type __c) const { - return isascii(__c) ? __tab_[static_cast<int>(__c)] & __m : false; + return isascii(__c) ? (__tab_[static_cast<int>(__c)] & __m) !=0 : false; } _LIBCPP_ALWAYS_INLINE @@ -619,7 +621,7 @@ protected: // template <class CharT> class ctype_byname; -template <class _CharT> class _LIBCPP_TYPE_VIS ctype_byname; +template <class _CharT> class _LIBCPP_TYPE_VIS_ONLY ctype_byname; template <> class _LIBCPP_TYPE_VIS ctype_byname<char> @@ -780,7 +782,7 @@ public: // template <class internT, class externT, class stateT> class codecvt; -template <class _InternT, class _ExternT, class _StateT> class _LIBCPP_TYPE_VIS codecvt; +template <class _InternT, class _ExternT, class _StateT> class _LIBCPP_TYPE_VIS_ONLY codecvt; // template <> class codecvt<char, char, mbstate_t> @@ -1126,7 +1128,7 @@ protected: // template <class _InternT, class _ExternT, class _StateT> class codecvt_byname template <class _InternT, class _ExternT, class _StateT> -class _LIBCPP_TYPE_VIS codecvt_byname +class _LIBCPP_TYPE_VIS_ONLY codecvt_byname : public codecvt<_InternT, _ExternT, _StateT> { public: @@ -1145,10 +1147,10 @@ codecvt_byname<_InternT, _ExternT, _StateT>::~codecvt_byname() { } -_LIBCPP_EXTERN_TEMPLATE(class codecvt_byname<char, char, mbstate_t>) -_LIBCPP_EXTERN_TEMPLATE(class codecvt_byname<wchar_t, char, mbstate_t>) -_LIBCPP_EXTERN_TEMPLATE(class codecvt_byname<char16_t, char, mbstate_t>) -_LIBCPP_EXTERN_TEMPLATE(class codecvt_byname<char32_t, char, mbstate_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<char, char, mbstate_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<wchar_t, char, mbstate_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<char16_t, char, mbstate_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS codecvt_byname<char32_t, char, mbstate_t>) _LIBCPP_FUNC_VIS void __throw_runtime_error(const char*); @@ -1334,7 +1336,7 @@ struct __widen_from_utf8<32> // template <class charT> class numpunct -template <class _CharT> class _LIBCPP_TYPE_VIS numpunct; +template <class _CharT> class _LIBCPP_TYPE_VIS_ONLY numpunct; template <> class _LIBCPP_TYPE_VIS numpunct<char> @@ -1400,7 +1402,7 @@ protected: // template <class charT> class numpunct_byname -template <class charT> class _LIBCPP_TYPE_VIS numpunct_byname; +template <class charT> class _LIBCPP_TYPE_VIS_ONLY numpunct_byname; template <> class _LIBCPP_TYPE_VIS numpunct_byname<char> diff --git a/system/include/libcxx/__mutex_base b/system/include/libcxx/__mutex_base index 0583df93..d4023a64 100644 --- a/system/include/libcxx/__mutex_base +++ b/system/include/libcxx/__mutex_base @@ -20,16 +20,6 @@ #pragma GCC system_header #endif -#ifdef _LIBCPP_SHARED_LOCK - -namespace ting { -template <class _Mutex> class shared_lock; -template <class _Mutex> class upgrade_lock; -} - -#endif // _LIBCPP_SHARED_LOCK - - _LIBCPP_BEGIN_NAMESPACE_STD class _LIBCPP_TYPE_VIS mutex @@ -77,7 +67,7 @@ constexpr adopt_lock_t adopt_lock = adopt_lock_t(); #endif template <class _Mutex> -class _LIBCPP_TYPE_VIS lock_guard +class _LIBCPP_TYPE_VIS_ONLY lock_guard { public: typedef _Mutex mutex_type; @@ -101,7 +91,7 @@ private: }; template <class _Mutex> -class _LIBCPP_TYPE_VIS unique_lock +class _LIBCPP_TYPE_VIS_ONLY unique_lock { public: typedef _Mutex mutex_type; @@ -162,27 +152,6 @@ public: return *this; } -#ifdef _LIBCPP_SHARED_LOCK - - unique_lock(ting::shared_lock<mutex_type>&&, try_to_lock_t); - template <class _Clock, class _Duration> - unique_lock(ting::shared_lock<mutex_type>&&, - const chrono::time_point<_Clock, _Duration>&); - template <class _Rep, class _Period> - unique_lock(ting::shared_lock<mutex_type>&&, - const chrono::duration<_Rep, _Period>&); - - explicit unique_lock(ting::upgrade_lock<mutex_type>&&); - unique_lock(ting::upgrade_lock<mutex_type>&&, try_to_lock_t); - template <class _Clock, class _Duration> - unique_lock(ting::upgrade_lock<mutex_type>&&, - const chrono::time_point<_Clock, _Duration>&); - template <class _Rep, class _Period> - unique_lock(ting::upgrade_lock<mutex_type>&&, - const chrono::duration<_Rep, _Period>&); - -#endif // _LIBCPP_SHARED_LOCK - #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES void lock(); diff --git a/system/include/libcxx/__split_buffer b/system/include/libcxx/__split_buffer index f1c404f7..1d529cbe 100644 --- a/system/include/libcxx/__split_buffer +++ b/system/include/libcxx/__split_buffer @@ -285,7 +285,7 @@ __split_buffer<_Tp, _Allocator>::__construct_at_end(_ForwardIterator __first, _F } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_type) { @@ -294,7 +294,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, false_ } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_type) { @@ -302,7 +302,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_begin(pointer __new_begin, true_t } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_type) _NOEXCEPT { @@ -311,7 +311,7 @@ __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, false_typ } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void __split_buffer<_Tp, _Allocator>::__destruct_at_end(pointer __new_last, true_type) _NOEXCEPT { @@ -328,7 +328,7 @@ __split_buffer<_Tp, _Allocator>::__split_buffer(size_type __cap, size_type __sta } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY __split_buffer<_Tp, _Allocator>::__split_buffer() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr) @@ -336,14 +336,14 @@ __split_buffer<_Tp, _Allocator>::__split_buffer() } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY __split_buffer<_Tp, _Allocator>::__split_buffer(__alloc_rr& __a) : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) { } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY __split_buffer<_Tp, _Allocator>::__split_buffer(const __alloc_rr& __a) : __first_(nullptr), __begin_(nullptr), __end_(nullptr), __end_cap_(nullptr, __a) { @@ -541,7 +541,7 @@ __split_buffer<_Tp, _Allocator>::push_front(value_type&& __x) #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void __split_buffer<_Tp, _Allocator>::push_back(const_reference __x) { @@ -640,7 +640,7 @@ __split_buffer<_Tp, _Allocator>::emplace_back(_Args&&... __args) #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void swap(__split_buffer<_Tp, _Allocator>& __x, __split_buffer<_Tp, _Allocator>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) diff --git a/system/include/libcxx/__std_stream b/system/include/libcxx/__std_stream index cff43317..5403adab 100644 --- a/system/include/libcxx/__std_stream +++ b/system/include/libcxx/__std_stream @@ -233,6 +233,7 @@ public: protected: virtual int_type overflow (int_type __c = traits_type::eof()); + virtual streamsize xsputn(const char_type* __s, streamsize __n); virtual int sync(); virtual void imbue(const locale& __loc); @@ -309,6 +310,19 @@ __stdoutbuf<_CharT>::overflow(int_type __c) } template <class _CharT> +streamsize +__stdoutbuf<_CharT>::xsputn(const char_type* __s, streamsize __n) +{ + if (__always_noconv_) + return fwrite(__s, sizeof(char_type), __n, __file_); + streamsize __i = 0; + for (; __i < __n; ++__i, ++__s) + if (overflow(traits_type::to_int_type(*__s)) == traits_type::eof()) + break; + return __i; +} + +template <class _CharT> int __stdoutbuf<_CharT>::sync() { diff --git a/system/include/libcxx/__tree b/system/include/libcxx/__tree index 9ffc38d2..acf87593 100644 --- a/system/include/libcxx/__tree +++ b/system/include/libcxx/__tree @@ -25,17 +25,17 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _Tp, class _Compare, class _Allocator> class __tree; template <class _Tp, class _NodePtr, class _DiffType> - class _LIBCPP_TYPE_VIS __tree_iterator; + class _LIBCPP_TYPE_VIS_ONLY __tree_iterator; template <class _Tp, class _ConstNodePtr, class _DiffType> - class _LIBCPP_TYPE_VIS __tree_const_iterator; + class _LIBCPP_TYPE_VIS_ONLY __tree_const_iterator; template <class _Key, class _Tp, class _Compare, class _Allocator> - class _LIBCPP_TYPE_VIS map; + class _LIBCPP_TYPE_VIS_ONLY map; template <class _Key, class _Tp, class _Compare, class _Allocator> - class _LIBCPP_TYPE_VIS multimap; + class _LIBCPP_TYPE_VIS_ONLY multimap; template <class _Key, class _Compare, class _Allocator> - class _LIBCPP_TYPE_VIS set; + class _LIBCPP_TYPE_VIS_ONLY set; template <class _Key, class _Compare, class _Allocator> - class _LIBCPP_TYPE_VIS multiset; + class _LIBCPP_TYPE_VIS_ONLY multiset; /* @@ -614,11 +614,11 @@ public: #endif // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_VARIADICS) }; -template <class _TreeIterator> class _LIBCPP_TYPE_VIS __map_iterator; -template <class _TreeIterator> class _LIBCPP_TYPE_VIS __map_const_iterator; +template <class _TreeIterator> class _LIBCPP_TYPE_VIS_ONLY __map_iterator; +template <class _TreeIterator> class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator; template <class _Tp, class _NodePtr, class _DiffType> -class _LIBCPP_TYPE_VIS __tree_iterator +class _LIBCPP_TYPE_VIS_ONLY __tree_iterator { typedef _NodePtr __node_pointer; typedef typename pointer_traits<__node_pointer>::element_type __node; @@ -641,7 +641,11 @@ public: #endif pointer; - _LIBCPP_INLINE_VISIBILITY __tree_iterator() _NOEXCEPT {} + _LIBCPP_INLINE_VISIBILITY __tree_iterator() _NOEXCEPT +#if _LIBCPP_STD_VER > 11 + : __ptr_(nullptr) +#endif + {} _LIBCPP_INLINE_VISIBILITY reference operator*() const {return __ptr_->__value_;} _LIBCPP_INLINE_VISIBILITY pointer operator->() const @@ -674,16 +678,16 @@ private: _LIBCPP_INLINE_VISIBILITY explicit __tree_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {} template <class, class, class> friend class __tree; - template <class, class, class> friend class _LIBCPP_TYPE_VIS __tree_const_iterator; - template <class> friend class _LIBCPP_TYPE_VIS __map_iterator; - template <class, class, class, class> friend class _LIBCPP_TYPE_VIS map; - template <class, class, class, class> friend class _LIBCPP_TYPE_VIS multimap; - template <class, class, class> friend class _LIBCPP_TYPE_VIS set; - template <class, class, class> friend class _LIBCPP_TYPE_VIS multiset; + template <class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY __tree_const_iterator; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY __map_iterator; + template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY map; + template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multimap; + template <class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY set; + template <class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multiset; }; template <class _Tp, class _ConstNodePtr, class _DiffType> -class _LIBCPP_TYPE_VIS __tree_const_iterator +class _LIBCPP_TYPE_VIS_ONLY __tree_const_iterator { typedef _ConstNodePtr __node_pointer; typedef typename pointer_traits<__node_pointer>::element_type __node; @@ -712,7 +716,12 @@ public: #endif pointer; - _LIBCPP_INLINE_VISIBILITY __tree_const_iterator() {} + _LIBCPP_INLINE_VISIBILITY __tree_const_iterator() _NOEXCEPT +#if _LIBCPP_STD_VER > 11 + : __ptr_(nullptr) +#endif + {} + private: typedef typename remove_const<__node>::type __non_const_node; typedef typename pointer_traits<__node_pointer>::template @@ -761,11 +770,11 @@ private: explicit __tree_const_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {} template <class, class, class> friend class __tree; - template <class, class, class, class> friend class _LIBCPP_TYPE_VIS map; - template <class, class, class, class> friend class _LIBCPP_TYPE_VIS multimap; - template <class, class, class> friend class _LIBCPP_TYPE_VIS set; - template <class, class, class> friend class _LIBCPP_TYPE_VIS multiset; - template <class> friend class _LIBCPP_TYPE_VIS __map_const_iterator; + template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY map; + template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multimap; + template <class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY set; + template <class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multiset; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator; }; template <class _Tp, class _Compare, class _Allocator> @@ -1107,8 +1116,8 @@ private: __node_pointer __detach(); static __node_pointer __detach(__node_pointer); - template <class, class, class, class> friend class _LIBCPP_TYPE_VIS map; - template <class, class, class, class> friend class _LIBCPP_TYPE_VIS multimap; + template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY map; + template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multimap; }; template <class _Tp, class _Compare, class _Allocator> @@ -1845,7 +1854,7 @@ __tree<_Tp, _Compare, _Allocator>::__construct_node(const value_type& __v) __node_holder __h(__node_traits::allocate(__na, 1), _Dp(__na)); __node_traits::construct(__na, _VSTD::addressof(__h->__value_), __v); __h.get_deleter().__value_constructed = true; - return _VSTD::move(__h); + return _VSTD::move(__h); // explicitly moved for C++03 } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES diff --git a/system/include/libcxx/__tuple b/system/include/libcxx/__tuple index 9a6b6e09..de35cb87 100644 --- a/system/include/libcxx/__tuple +++ b/system/include/libcxx/__tuple @@ -27,46 +27,46 @@ _LIBCPP_BEGIN_NAMESPACE_STD -template <class _Tp> class _LIBCPP_TYPE_VIS tuple_size; +template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_size; template <class _Tp> -class _LIBCPP_TYPE_VIS tuple_size<const _Tp> +class _LIBCPP_TYPE_VIS_ONLY tuple_size<const _Tp> : public tuple_size<_Tp> {}; template <class _Tp> -class _LIBCPP_TYPE_VIS tuple_size<volatile _Tp> +class _LIBCPP_TYPE_VIS_ONLY tuple_size<volatile _Tp> : public tuple_size<_Tp> {}; template <class _Tp> -class _LIBCPP_TYPE_VIS tuple_size<const volatile _Tp> +class _LIBCPP_TYPE_VIS_ONLY tuple_size<const volatile _Tp> : public tuple_size<_Tp> {}; -template <size_t _Ip, class _Tp> class _LIBCPP_TYPE_VIS tuple_element; +template <size_t _Ip, class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_element; template <size_t _Ip, class _Tp> -class _LIBCPP_TYPE_VIS tuple_element<_Ip, const _Tp> +class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, const _Tp> { public: typedef typename add_const<typename tuple_element<_Ip, _Tp>::type>::type type; }; template <size_t _Ip, class _Tp> -class _LIBCPP_TYPE_VIS tuple_element<_Ip, volatile _Tp> +class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, volatile _Tp> { public: typedef typename add_volatile<typename tuple_element<_Ip, _Tp>::type>::type type; }; template <size_t _Ip, class _Tp> -class _LIBCPP_TYPE_VIS tuple_element<_Ip, const volatile _Tp> +class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, const volatile _Tp> { public: typedef typename add_cv<typename tuple_element<_Ip, _Tp>::type>::type type; }; -template <class ..._Tp> class _LIBCPP_TYPE_VIS tuple; -template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS pair; -template <class _Tp, size_t _Size> struct _LIBCPP_TYPE_VIS array; +template <class ..._Tp> class _LIBCPP_TYPE_VIS_ONLY tuple; +template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY pair; +template <class _Tp, size_t _Size> struct _LIBCPP_TYPE_VIS_ONLY array; template <class _Tp> struct __tuple_like : false_type {}; @@ -154,7 +154,7 @@ struct __make_tuple_indices template <class ..._Tp> struct __tuple_types {}; template <size_t _Ip> -class _LIBCPP_TYPE_VIS tuple_element<_Ip, __tuple_types<> > +class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, __tuple_types<> > { public: static_assert(_Ip == 0, "tuple_element index out of range"); @@ -162,21 +162,21 @@ public: }; template <class _Hp, class ..._Tp> -class _LIBCPP_TYPE_VIS tuple_element<0, __tuple_types<_Hp, _Tp...> > +class _LIBCPP_TYPE_VIS_ONLY tuple_element<0, __tuple_types<_Hp, _Tp...> > { public: typedef _Hp type; }; template <size_t _Ip, class _Hp, class ..._Tp> -class _LIBCPP_TYPE_VIS tuple_element<_Ip, __tuple_types<_Hp, _Tp...> > +class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, __tuple_types<_Hp, _Tp...> > { public: typedef typename tuple_element<_Ip-1, __tuple_types<_Tp...> >::type type; }; template <class ..._Tp> -class _LIBCPP_TYPE_VIS tuple_size<__tuple_types<_Tp...> > +class _LIBCPP_TYPE_VIS_ONLY tuple_size<__tuple_types<_Tp...> > : public integral_constant<size_t, sizeof...(_Tp)> { }; diff --git a/system/include/libcxx/__tuple_03 b/system/include/libcxx/__tuple_03 index 605d84df..b91c2cd4 100644 --- a/system/include/libcxx/__tuple_03 +++ b/system/include/libcxx/__tuple_03 @@ -19,8 +19,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD -template <class _Tp> class _LIBCPP_TYPE_VIS tuple_size; -template <size_t _Ip, class _Tp> class _LIBCPP_TYPE_VIS tuple_element; +template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_size; +template <size_t _Ip, class _Tp> class _LIBCPP_TYPE_VIS_ONLY tuple_element; _LIBCPP_END_NAMESPACE_STD diff --git a/system/include/libcxx/__undef_min_max b/system/include/libcxx/__undef_min_max index b1e80d1b..2b6bc90a 100644 --- a/system/include/libcxx/__undef_min_max +++ b/system/include/libcxx/__undef_min_max @@ -9,11 +9,19 @@ //===----------------------------------------------------------------------===// #ifdef min +#if defined(_MSC_VER) && ! defined(__clang__) +_LIBCPP_WARNING("macro min is incompatible with C++. #undefing min") +#else #warning: macro min is incompatible with C++. #undefing min +#endif #undef min #endif #ifdef max +#if defined(_MSC_VER) && ! defined(__clang__) +_LIBCPP_WARNING("macro max is incompatible with C++. #undefing max") +#else #warning: macro max is incompatible with C++. #undefing max +#endif #undef max #endif diff --git a/system/include/libcxx/algorithm b/system/include/libcxx/algorithm index 2fc1f8ab..367489fb 100644 --- a/system/include/libcxx/algorithm +++ b/system/include/libcxx/algorithm @@ -628,6 +628,13 @@ template <class BidirectionalIterator, class Compare> #include <iterator> #include <cstddef> +#if defined(__IBMCPP__) +#include "support/ibm/support.h" +#endif +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) +#include "support/win32/support.h" +#endif + #include <__undef_min_max> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) @@ -710,7 +717,7 @@ public: bool operator()(const _T1& __x, const _T2& __y) {return !__p_(__x, __y);} }; -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG template <class _Compare> struct __debug_less @@ -727,7 +734,7 @@ struct __debug_less } }; -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG // Precondition: __x != 0 inline _LIBCPP_INLINE_VISIBILITY @@ -825,7 +832,7 @@ for_each(_InputIterator __first, _InputIterator __last, _Function __f) { for (; __first != __last; ++__first) __f(*__first); - return _VSTD::move(__f); + return _VSTD::move(__f); // explicitly moved for (emulated) C++03 } // find @@ -1688,6 +1695,8 @@ __unwrap_iter(move_iterator<_Tp*> __i) return __i.base(); } +#if _LIBCPP_DEBUG_LEVEL < 2 + template <class _Tp> inline _LIBCPP_INLINE_VISIBILITY typename enable_if @@ -1700,6 +1709,8 @@ __unwrap_iter(__wrap_iter<_Tp*> __i) return __i.base(); } +#endif // _LIBCPP_DEBUG_LEVEL < 2 + template <class _InputIterator, class _OutputIterator> inline _LIBCPP_INLINE_VISIBILITY _OutputIterator @@ -2964,11 +2975,11 @@ uniform_int_distribution<_IntType>::operator()(_URNG& __g, const param_type& __p return static_cast<result_type>(__u + __p.a()); } -class __rs_default; +class _LIBCPP_TYPE_VIS __rs_default; -__rs_default __rs_get(); +_LIBCPP_FUNC_VIS __rs_default __rs_get(); -class __rs_default +class _LIBCPP_TYPE_VIS __rs_default { static unsigned __c_; @@ -2987,10 +2998,10 @@ public: static _LIBCPP_CONSTEXPR result_type min() {return _Min;} static _LIBCPP_CONSTEXPR result_type max() {return _Max;} - friend __rs_default __rs_get(); + friend _LIBCPP_FUNC_VIS __rs_default __rs_get(); }; -__rs_default __rs_get(); +_LIBCPP_FUNC_VIS __rs_default __rs_get(); template <class _RandomAccessIterator> void @@ -3945,14 +3956,14 @@ inline _LIBCPP_INLINE_VISIBILITY void sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __sort<_Comp_ref>(__first, __last, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __sort<_Comp_ref>(__first, __last, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _RandomAccessIterator> @@ -3992,39 +4003,39 @@ sort(__wrap_iter<_Tp*> __first, __wrap_iter<_Tp*> __last, _Compare __comp) #pragma warning( push ) #pragma warning( disable: 4231) #endif // _LIBCPP_MSVC -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<char>&, char*>(char*, char*, __less<char>&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<short>&, short*>(short*, short*, __less<short>&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<int>&, int*>(int*, int*, __less<int>&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<long>&, long*>(long*, long*, __less<long>&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<float>&, float*>(float*, float*, __less<float>&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<double>&, double*>(double*, double*, __less<double>&)) -_LIBCPP_EXTERN_TEMPLATE(void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&)) - -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<int>&, int*>(int*, int*, __less<int>&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<long>&, long*>(long*, long*, __less<long>&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<long long>&, long long*>(long long*, long long*, __less<long long>&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<float>&, float*>(float*, float*, __less<float>&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<double>&, double*>(double*, double*, __less<double>&)) -_LIBCPP_EXTERN_TEMPLATE(bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&)) - -_LIBCPP_EXTERN_TEMPLATE(unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<char>&, char*>(char*, char*, __less<char>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<short>&, short*>(short*, short*, __less<short>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<int>&, int*>(int*, int*, __less<int>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<long>&, long*>(long*, long*, __less<long>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<long long>&, long long*>(long long*, long long*, __less<long long>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<float>&, float*>(float*, float*, __less<float>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<double>&, double*>(double*, double*, __less<double>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void __sort<__less<long double>&, long double*>(long double*, long double*, __less<long double>&)) + +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<char>&, char*>(char*, char*, __less<char>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<wchar_t>&, wchar_t*>(wchar_t*, wchar_t*, __less<wchar_t>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<signed char>&, signed char*>(signed char*, signed char*, __less<signed char>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned char>&, unsigned char*>(unsigned char*, unsigned char*, __less<unsigned char>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<short>&, short*>(short*, short*, __less<short>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned short>&, unsigned short*>(unsigned short*, unsigned short*, __less<unsigned short>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<int>&, int*>(int*, int*, __less<int>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned>&, unsigned*>(unsigned*, unsigned*, __less<unsigned>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long>&, long*>(long*, long*, __less<long>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned long>&, unsigned long*>(unsigned long*, unsigned long*, __less<unsigned long>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long long>&, long long*>(long long*, long long*, __less<long long>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<unsigned long long>&, unsigned long long*>(unsigned long long*, unsigned long long*, __less<unsigned long long>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<float>&, float*>(float*, float*, __less<float>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<double>&, double*>(double*, double*, __less<double>&)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS bool __insertion_sort_incomplete<__less<long double>&, long double*>(long double*, long double*, __less<long double>&)) + +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS unsigned __sort5<__less<long double>&, long double*>(long double*, long double*, long double*, long double*, long double*, __less<long double>&)) #ifdef _LIBCPP_MSVC #pragma warning( pop ) #endif // _LIBCPP_MSVC @@ -4058,14 +4069,14 @@ inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator lower_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __lower_bound<_Comp_ref>(__first, __last, __value_, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __lower_bound<_Comp_ref>(__first, __last, __value_, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _ForwardIterator, class _Tp> @@ -4106,14 +4117,14 @@ inline _LIBCPP_INLINE_VISIBILITY _ForwardIterator upper_bound(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __upper_bound<_Comp_ref>(__first, __last, __value_, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __upper_bound<_Comp_ref>(__first, __last, __value_, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _ForwardIterator, class _Tp> @@ -4166,14 +4177,14 @@ inline _LIBCPP_INLINE_VISIBILITY pair<_ForwardIterator, _ForwardIterator> equal_range(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __equal_range<_Comp_ref>(__first, __last, __value_, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __equal_range<_Comp_ref>(__first, __last, __value_, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _ForwardIterator, class _Tp> @@ -4201,14 +4212,14 @@ inline _LIBCPP_INLINE_VISIBILITY bool binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value_, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __binary_search<_Comp_ref>(__first, __last, __value_, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __binary_search<_Comp_ref>(__first, __last, __value_, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _ForwardIterator, class _Tp> @@ -4251,14 +4262,14 @@ _OutputIterator merge(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return _VSTD::__merge<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return _VSTD::__merge<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _InputIterator1, class _InputIterator2, class _OutputIterator> @@ -4425,16 +4436,16 @@ inplace_merge(_BidirectionalIterator __first, _BidirectionalIterator __middle, _ __buf = _VSTD::get_temporary_buffer<value_type>(__buf_size); __h.reset(__buf.first); } -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return _VSTD::__inplace_merge<_Comp_ref>(__first, __middle, __last, __c, __len1, __len2, __buf.first, __buf.second); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return _VSTD::__inplace_merge<_Comp_ref>(__first, __middle, __last, __comp, __len1, __len2, __buf.first, __buf.second); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _BidirectionalIterator> @@ -4636,14 +4647,14 @@ stable_sort(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compar __buf = _VSTD::get_temporary_buffer<value_type>(__len); __h.reset(__buf.first); } -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __stable_sort<_Comp_ref>(__first, __last, __c, __len, __buf.first, __buf.second); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __stable_sort<_Comp_ref>(__first, __last, __comp, __len, __buf.first, __buf.second); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _RandomAccessIterator> @@ -4785,14 +4796,14 @@ inline _LIBCPP_INLINE_VISIBILITY void push_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __push_heap_back<_Comp_ref>(__first, __last, __c, __last - __first); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __push_heap_back<_Comp_ref>(__first, __last, __comp, __last - __first); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _RandomAccessIterator> @@ -4823,14 +4834,14 @@ inline _LIBCPP_INLINE_VISIBILITY void pop_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __pop_heap<_Comp_ref>(__first, __last, __c, __last - __first); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __pop_heap<_Comp_ref>(__first, __last, __comp, __last - __first); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _RandomAccessIterator> @@ -4863,14 +4874,14 @@ inline _LIBCPP_INLINE_VISIBILITY void make_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __make_heap<_Comp_ref>(__first, __last, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __make_heap<_Comp_ref>(__first, __last, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _RandomAccessIterator> @@ -4897,14 +4908,14 @@ inline _LIBCPP_INLINE_VISIBILITY void sort_heap(_RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __sort_heap<_Comp_ref>(__first, __last, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __sort_heap<_Comp_ref>(__first, __last, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _RandomAccessIterator> @@ -4941,14 +4952,14 @@ void partial_sort(_RandomAccessIterator __first, _RandomAccessIterator __middle, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __partial_sort<_Comp_ref>(__first, __middle, __last, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __partial_sort<_Comp_ref>(__first, __middle, __last, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _RandomAccessIterator> @@ -4991,14 +5002,14 @@ _RandomAccessIterator partial_sort_copy(_InputIterator __first, _InputIterator __last, _RandomAccessIterator __result_first, _RandomAccessIterator __result_last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __partial_sort_copy<_Comp_ref>(__first, __last, __result_first, __result_last, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _InputIterator, class _RandomAccessIterator> @@ -5205,14 +5216,14 @@ inline _LIBCPP_INLINE_VISIBILITY void nth_element(_RandomAccessIterator __first, _RandomAccessIterator __nth, _RandomAccessIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); __nth_element<_Comp_ref>(__first, __nth, __last, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; __nth_element<_Comp_ref>(__first, __nth, __last, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _RandomAccessIterator> @@ -5246,14 +5257,14 @@ bool includes(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __includes<_Comp_ref>(__first1, __last1, __first2, __last2, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __includes<_Comp_ref>(__first1, __last1, __first2, __last2, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _InputIterator1, class _InputIterator2> @@ -5299,14 +5310,14 @@ _OutputIterator set_union(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __set_union<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _InputIterator1, class _InputIterator2, class _OutputIterator> @@ -5351,14 +5362,14 @@ _OutputIterator set_intersection(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __set_intersection<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _InputIterator1, class _InputIterator2, class _OutputIterator> @@ -5405,14 +5416,14 @@ _OutputIterator set_difference(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __set_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _InputIterator1, class _InputIterator2, class _OutputIterator> @@ -5464,14 +5475,14 @@ _OutputIterator set_symmetric_difference(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _OutputIterator __result, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __set_symmetric_difference<_Comp_ref>(__first1, __last1, __first2, __last2, __result, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _InputIterator1, class _InputIterator2, class _OutputIterator> @@ -5508,14 +5519,14 @@ bool lexicographical_compare(_InputIterator1 __first1, _InputIterator1 __last1, _InputIterator2 __first2, _InputIterator2 __last2, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __lexicographical_compare<_Comp_ref>(__first1, __last1, __first2, __last2, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __lexicographical_compare<_Comp_ref>(__first1, __last1, __first2, __last2, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _InputIterator1, class _InputIterator2> @@ -5563,14 +5574,14 @@ inline _LIBCPP_INLINE_VISIBILITY bool next_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __next_permutation<_Comp_ref>(__first, __last, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __next_permutation<_Comp_ref>(__first, __last, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _BidirectionalIterator> @@ -5616,14 +5627,14 @@ inline _LIBCPP_INLINE_VISIBILITY bool prev_permutation(_BidirectionalIterator __first, _BidirectionalIterator __last, _Compare __comp) { -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG typedef typename add_lvalue_reference<__debug_less<_Compare> >::type _Comp_ref; __debug_less<_Compare> __c(__comp); return __prev_permutation<_Comp_ref>(__first, __last, __c); -#else // _LIBCPP_DEBUG2 +#else // _LIBCPP_DEBUG typedef typename add_lvalue_reference<_Compare>::type _Comp_ref; return __prev_permutation<_Comp_ref>(__first, __last, __comp); -#endif // _LIBCPP_DEBUG2 +#endif // _LIBCPP_DEBUG } template <class _BidirectionalIterator> diff --git a/system/include/libcxx/array b/system/include/libcxx/array index 86d1fc0b..d37075da 100644 --- a/system/include/libcxx/array +++ b/system/include/libcxx/array @@ -118,7 +118,7 @@ template <int I, class T, size_t N> T&& get(array<T, N>&&) noexcept; // constexp _LIBCPP_BEGIN_NAMESPACE_STD template <class _Tp, size_t _Size> -struct _LIBCPP_TYPE_VIS array +struct _LIBCPP_TYPE_VIS_ONLY array { // types: typedef array __self; @@ -224,7 +224,7 @@ array<_Tp, _Size>::at(size_type __n) const } template <class _Tp, size_t _Size> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { @@ -232,7 +232,7 @@ operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) } template <class _Tp, size_t _Size> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { @@ -240,7 +240,7 @@ operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) } template <class _Tp, size_t _Size> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { @@ -248,7 +248,7 @@ operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) } template <class _Tp, size_t _Size> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { @@ -256,7 +256,7 @@ operator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) } template <class _Tp, size_t _Size> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { @@ -264,7 +264,7 @@ operator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) } template <class _Tp, size_t _Size> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { @@ -272,7 +272,7 @@ operator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) } template <class _Tp, size_t _Size> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename enable_if < __is_swappable<_Tp>::value, @@ -285,29 +285,29 @@ swap(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) } template <class _Tp, size_t _Size> -class _LIBCPP_TYPE_VIS tuple_size<array<_Tp, _Size> > +class _LIBCPP_TYPE_VIS_ONLY tuple_size<array<_Tp, _Size> > : public integral_constant<size_t, _Size> {}; template <class _Tp, size_t _Size> -class _LIBCPP_TYPE_VIS tuple_size<const array<_Tp, _Size> > +class _LIBCPP_TYPE_VIS_ONLY tuple_size<const array<_Tp, _Size> > : public integral_constant<size_t, _Size> {}; template <size_t _Ip, class _Tp, size_t _Size> -class _LIBCPP_TYPE_VIS tuple_element<_Ip, array<_Tp, _Size> > +class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, array<_Tp, _Size> > { public: typedef _Tp type; }; template <size_t _Ip, class _Tp, size_t _Size> -class _LIBCPP_TYPE_VIS tuple_element<_Ip, const array<_Tp, _Size> > +class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, const array<_Tp, _Size> > { public: typedef const _Tp type; }; template <size_t _Ip, class _Tp, size_t _Size> -_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_CONSTEXPR_AFTER_CXX11 +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp& get(array<_Tp, _Size>& __a) _NOEXCEPT { @@ -316,7 +316,7 @@ get(array<_Tp, _Size>& __a) _NOEXCEPT } template <size_t _Ip, class _Tp, size_t _Size> -_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_CONSTEXPR_AFTER_CXX11 +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const _Tp& get(const array<_Tp, _Size>& __a) _NOEXCEPT { @@ -327,7 +327,7 @@ get(const array<_Tp, _Size>& __a) _NOEXCEPT #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template <size_t _Ip, class _Tp, size_t _Size> -_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_CONSTEXPR_AFTER_CXX11 +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 _Tp&& get(array<_Tp, _Size>&& __a) _NOEXCEPT { diff --git a/system/include/libcxx/bitset b/system/include/libcxx/bitset index dd9be4fc..4cc7dbda 100644 --- a/system/include/libcxx/bitset +++ b/system/include/libcxx/bitset @@ -632,11 +632,11 @@ __bitset<0, 0>::__bitset(unsigned long long) _NOEXCEPT { } -template <size_t _Size> class _LIBCPP_TYPE_VIS bitset; -template <size_t _Size> struct _LIBCPP_TYPE_VIS hash<bitset<_Size> >; +template <size_t _Size> class _LIBCPP_TYPE_VIS_ONLY bitset; +template <size_t _Size> struct _LIBCPP_TYPE_VIS_ONLY hash<bitset<_Size> >; template <size_t _Size> -class _LIBCPP_TYPE_VIS bitset +class _LIBCPP_TYPE_VIS_ONLY bitset : private __bitset<_Size == 0 ? 0 : (_Size - 1) / (sizeof(size_t) * CHAR_BIT) + 1, _Size> { public: @@ -1060,7 +1060,7 @@ operator^(const bitset<_Size>& __x, const bitset<_Size>& __y) _NOEXCEPT } template <size_t _Size> -struct _LIBCPP_TYPE_VIS hash<bitset<_Size> > +struct _LIBCPP_TYPE_VIS_ONLY hash<bitset<_Size> > : public unary_function<bitset<_Size>, size_t> { _LIBCPP_INLINE_VISIBILITY diff --git a/system/include/libcxx/chrono b/system/include/libcxx/chrono index da550498..2c65eee7 100644 --- a/system/include/libcxx/chrono +++ b/system/include/libcxx/chrono @@ -292,7 +292,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD namespace chrono { -template <class _Rep, class _Period = ratio<1> > class _LIBCPP_TYPE_VIS duration; +template <class _Rep, class _Period = ratio<1> > class _LIBCPP_TYPE_VIS_ONLY duration; template <class _Tp> struct __is_duration : false_type {}; @@ -312,8 +312,8 @@ struct __is_duration<const volatile duration<_Rep, _Period> > : true_type {}; } // chrono template <class _Rep1, class _Period1, class _Rep2, class _Period2> -struct _LIBCPP_TYPE_VIS common_type<chrono::duration<_Rep1, _Period1>, - chrono::duration<_Rep2, _Period2> > +struct _LIBCPP_TYPE_VIS_ONLY common_type<chrono::duration<_Rep1, _Period1>, + chrono::duration<_Rep2, _Period2> > { typedef chrono::duration<typename common_type<_Rep1, _Rep2>::type, typename __ratio_gcd<_Period1, _Period2>::type> type; @@ -390,10 +390,10 @@ duration_cast(const duration<_Rep, _Period>& __fd) } template <class _Rep> -struct _LIBCPP_TYPE_VIS treat_as_floating_point : is_floating_point<_Rep> {}; +struct _LIBCPP_TYPE_VIS_ONLY treat_as_floating_point : is_floating_point<_Rep> {}; template <class _Rep> -struct _LIBCPP_TYPE_VIS duration_values +struct _LIBCPP_TYPE_VIS_ONLY duration_values { public: _LIBCPP_INLINE_VISIBILITY static _LIBCPP_CONSTEXPR _Rep zero() {return _Rep(0);} @@ -404,11 +404,42 @@ public: // duration template <class _Rep, class _Period> -class _LIBCPP_TYPE_VIS duration +class _LIBCPP_TYPE_VIS_ONLY duration { static_assert(!__is_duration<_Rep>::value, "A duration representation can not be a duration"); static_assert(__is_ratio<_Period>::value, "Second template parameter of duration must be a std::ratio"); static_assert(_Period::num > 0, "duration period must be positive"); + + template <class _R1, class _R2> + struct __no_overflow + { + private: + static const intmax_t __gcd_n1_n2 = __static_gcd<_R1::num, _R2::num>::value; + static const intmax_t __gcd_d1_d2 = __static_gcd<_R1::den, _R2::den>::value; + static const intmax_t __n1 = _R1::num / __gcd_n1_n2; + static const intmax_t __d1 = _R1::den / __gcd_d1_d2; + static const intmax_t __n2 = _R2::num / __gcd_n1_n2; + static const intmax_t __d2 = _R2::den / __gcd_d1_d2; + static const intmax_t max = -((intmax_t(1) << (sizeof(intmax_t) * CHAR_BIT - 1)) + 1); + + template <intmax_t _Xp, intmax_t _Yp, bool __overflow> + struct __mul // __overflow == false + { + static const intmax_t value = _Xp * _Yp; + }; + + template <intmax_t _Xp, intmax_t _Yp> + struct __mul<_Xp, _Yp, true> + { + static const intmax_t value = 1; + }; + + public: + static const bool value = (__n1 <= max / __d2) && (__n2 <= max / __d1); + typedef ratio<__mul<__n1, __d2, !value>::value, + __mul<__n2, __d1, !value>::value> type; + }; + public: typedef _Rep rep; typedef _Period period; @@ -440,9 +471,10 @@ public: duration(const duration<_Rep2, _Period2>& __d, typename enable_if < + __no_overflow<_Period2, period>::value && ( treat_as_floating_point<rep>::value || - (ratio_divide<_Period2, period>::type::den == 1 && - !treat_as_floating_point<_Rep2>::value) + (__no_overflow<_Period2, period>::type::den == 1 && + !treat_as_floating_point<_Rep2>::value)) >::type* = 0) : __rep_(_VSTD::chrono::duration_cast<duration>(__d).count()) {} @@ -715,7 +747,7 @@ operator%(const duration<_Rep1, _Period1>& __lhs, const duration<_Rep2, _Period2 ////////////////////////////////////////////////////////// template <class _Clock, class _Duration = typename _Clock::duration> -class _LIBCPP_TYPE_VIS time_point +class _LIBCPP_TYPE_VIS_ONLY time_point { static_assert(__is_duration<_Duration>::value, "Second template parameter of time_point must be a std::chrono::duration"); @@ -759,8 +791,8 @@ public: } // chrono template <class _Clock, class _Duration1, class _Duration2> -struct _LIBCPP_TYPE_VIS common_type<chrono::time_point<_Clock, _Duration1>, - chrono::time_point<_Clock, _Duration2> > +struct _LIBCPP_TYPE_VIS_ONLY common_type<chrono::time_point<_Clock, _Duration1>, + chrono::time_point<_Clock, _Duration2> > { typedef chrono::time_point<_Clock, typename common_type<_Duration1, _Duration2>::type> type; }; @@ -910,12 +942,9 @@ typedef steady_clock high_resolution_clock; } // chrono -#if _LIBCPP_STD_VER > 11 -// Literal suffixes for chrono types -// inline // Deviation from N3690. -// We believe the inline to be a defect and have submitted an LWG issue. -// An LWG issue number has not yet been assigned. -namespace literals +#if _LIBCPP_STD_VER > 11 +// Suffixes for duration literals [time.duration.literals] +inline namespace literals { inline namespace chrono_literals { @@ -986,6 +1015,11 @@ namespace literals } }} + +namespace chrono { // hoist the literals into namespace std::chrono + using namespace literals::chrono_literals; +} + #endif _LIBCPP_END_NAMESPACE_STD diff --git a/system/include/libcxx/cmath b/system/include/libcxx/cmath index 3e545cea..75087ae7 100644 --- a/system/include/libcxx/cmath +++ b/system/include/libcxx/cmath @@ -654,6 +654,7 @@ using ::double_t; // abs +#if !defined(_AIX) inline _LIBCPP_INLINE_VISIBILITY float abs(float __x) _NOEXCEPT {return fabsf(__x);} @@ -665,6 +666,7 @@ abs(double __x) _NOEXCEPT {return fabs(__x);} inline _LIBCPP_INLINE_VISIBILITY long double abs(long double __x) _NOEXCEPT {return fabsl(__x);} +#endif // !defined(_AIX) #ifndef __sun__ @@ -673,7 +675,7 @@ abs(long double __x) _NOEXCEPT {return fabsl(__x);} using ::acos; using ::acosf; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float acos(float __x) _NOEXCEPT {return acosf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __x) _NOEXCEPT {return acosl(__x);} #endif @@ -688,7 +690,7 @@ acos(_A1 __x) _NOEXCEPT {return acos((double)__x);} using ::asin; using ::asinf; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float asin(float __x) _NOEXCEPT {return asinf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __x) _NOEXCEPT {return asinl(__x);} #endif @@ -703,7 +705,7 @@ asin(_A1 __x) _NOEXCEPT {return asin((double)__x);} using ::atan; using ::atanf; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float atan(float __x) _NOEXCEPT {return atanf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __x) _NOEXCEPT {return atanl(__x);} #endif @@ -718,7 +720,7 @@ atan(_A1 __x) _NOEXCEPT {return atan((double)__x);} using ::atan2; using ::atan2f; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float atan2(float __y, float __x) _NOEXCEPT {return atan2f(__y, __x);} inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __y, long double __x) _NOEXCEPT {return atan2l(__y, __x);} #endif @@ -744,7 +746,7 @@ atan2(_A1 __y, _A2 __x) _NOEXCEPT using ::ceil; using ::ceilf; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float ceil(float __x) _NOEXCEPT {return ceilf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __x) _NOEXCEPT {return ceill(__x);} #endif @@ -759,13 +761,13 @@ ceil(_A1 __x) _NOEXCEPT {return ceil((double)__x);} using ::cos; using ::cosf; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float cos(float __x) _NOEXCEPT {return cosf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __x) _NOEXCEPT {return cosl(__x);} #endif template <class _A1> -inline _LIBCPP_ALWAYS_INLINE _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY typename enable_if<is_integral<_A1>::value, double>::type cos(_A1 __x) _NOEXCEPT {return cos((double)__x);} @@ -774,7 +776,7 @@ cos(_A1 __x) _NOEXCEPT {return cos((double)__x);} using ::cosh; using ::coshf; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float cosh(float __x) _NOEXCEPT {return coshf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __x) _NOEXCEPT {return coshl(__x);} #endif @@ -792,7 +794,7 @@ using ::expf; #ifndef __sun__ -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float exp(float __x) _NOEXCEPT {return expf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __x) _NOEXCEPT {return expl(__x);} #endif @@ -808,7 +810,7 @@ exp(_A1 __x) _NOEXCEPT {return exp((double)__x);} using ::fabs; using ::fabsf; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float fabs(float __x) _NOEXCEPT {return fabsf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __x) _NOEXCEPT {return fabsl(__x);} #endif @@ -823,7 +825,7 @@ fabs(_A1 __x) _NOEXCEPT {return fabs((double)__x);} using ::floor; using ::floorf; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float floor(float __x) _NOEXCEPT {return floorf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __x) _NOEXCEPT {return floorl(__x);} #endif @@ -840,7 +842,7 @@ using ::fmod; using ::fmodf; #ifndef __sun__ -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float fmod(float __x, float __y) _NOEXCEPT {return fmodf(__x, __y);} inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __x, long double __y) _NOEXCEPT {return fmodl(__x, __y);} #endif @@ -867,7 +869,7 @@ fmod(_A1 __x, _A2 __y) _NOEXCEPT using ::frexp; using ::frexpf; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float frexp(float __x, int* __e) _NOEXCEPT {return frexpf(__x, __e);} inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __x, int* __e) _NOEXCEPT {return frexpl(__x, __e);} #endif @@ -882,7 +884,7 @@ frexp(_A1 __x, int* __e) _NOEXCEPT {return frexp((double)__x, __e);} using ::ldexp; using ::ldexpf; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __x, int __e) _NOEXCEPT {return ldexpf(__x, __e);} inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __x, int __e) _NOEXCEPT {return ldexpl(__x, __e);} #endif @@ -899,7 +901,7 @@ using ::log; using ::logf; #ifndef __sun__ -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float log(float __x) _NOEXCEPT {return logf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double log(long double __x) _NOEXCEPT {return logl(__x);} #endif @@ -915,7 +917,7 @@ log(_A1 __x) _NOEXCEPT {return log((double)__x);} using ::log10; using ::log10f; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float log10(float __x) _NOEXCEPT {return log10f(__x);} inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __x) _NOEXCEPT {return log10l(__x);} #endif @@ -930,7 +932,7 @@ log10(_A1 __x) _NOEXCEPT {return log10((double)__x);} using ::modf; using ::modff; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float modf(float __x, float* __y) _NOEXCEPT {return modff(__x, __y);} inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __x, long double* __y) _NOEXCEPT {return modfl(__x, __y);} #endif @@ -943,7 +945,7 @@ using ::powf; #ifndef __sun__ -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float pow(float __x, float __y) _NOEXCEPT {return powf(__x, __y);} inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __x, long double __y) _NOEXCEPT {return powl(__x, __y);} #endif @@ -970,7 +972,7 @@ pow(_A1 __x, _A2 __y) _NOEXCEPT using ::sin; using ::sinf; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float sin(float __x) _NOEXCEPT {return sinf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __x) _NOEXCEPT {return sinl(__x);} #endif @@ -985,7 +987,7 @@ sin(_A1 __x) _NOEXCEPT {return sin((double)__x);} using ::sinh; using ::sinhf; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float sinh(float __x) _NOEXCEPT {return sinhf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __x) _NOEXCEPT {return sinhl(__x);} #endif @@ -1002,7 +1004,7 @@ using ::sqrt; using ::sqrtf; -#if !(defined(_LIBCPP_MSVCRT) || defined(__sun__)) +#if !(defined(_LIBCPP_MSVCRT) || defined(__sun__) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __x) _NOEXCEPT {return sqrtf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __x) _NOEXCEPT {return sqrtl(__x);} #endif @@ -1018,7 +1020,7 @@ using ::tan; using ::tanf; #ifndef __sun__ -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float tan(float __x) _NOEXCEPT {return tanf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __x) _NOEXCEPT {return tanl(__x);} #endif @@ -1033,7 +1035,7 @@ tan(_A1 __x) _NOEXCEPT {return tan((double)__x);} using ::tanh; using ::tanhf; -#ifndef _LIBCPP_MSVCRT +#if !(defined(_LIBCPP_MSVCRT) || defined(_AIX)) inline _LIBCPP_INLINE_VISIBILITY float tanh(float __x) _NOEXCEPT {return tanhf(__x);} inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __x) _NOEXCEPT {return tanhl(__x);} #endif diff --git a/system/include/libcxx/codecvt b/system/include/libcxx/codecvt index a6e4308e..6eff107c 100644 --- a/system/include/libcxx/codecvt +++ b/system/include/libcxx/codecvt @@ -29,7 +29,8 @@ template <class Elem, unsigned long Maxcode = 0x10ffff, class codecvt_utf8 : public codecvt<Elem, char, mbstate_t> { - // unspecified + explicit codecvt_utf8(size_t refs = 0); + ~codecvt_utf8(); }; template <class Elem, unsigned long Maxcode = 0x10ffff, @@ -37,7 +38,8 @@ template <class Elem, unsigned long Maxcode = 0x10ffff, class codecvt_utf16 : public codecvt<Elem, char, mbstate_t> { - // unspecified + explicit codecvt_utf16(size_t refs = 0); + ~codecvt_utf16(); }; template <class Elem, unsigned long Maxcode = 0x10ffff, @@ -45,7 +47,8 @@ template <class Elem, unsigned long Maxcode = 0x10ffff, class codecvt_utf8_utf16 : public codecvt<Elem, char, mbstate_t> { - // unspecified + explicit codecvt_utf8_utf16(size_t refs = 0); + ~codecvt_utf8_utf16(); }; } // std @@ -73,7 +76,7 @@ enum codecvt_mode template <class _Elem> class __codecvt_utf8; template <> -class __codecvt_utf8<wchar_t> +class _LIBCPP_TYPE_VIS __codecvt_utf8<wchar_t> : public codecvt<wchar_t, char, mbstate_t> { unsigned long _Maxcode_; @@ -108,7 +111,7 @@ protected: }; template <> -class __codecvt_utf8<char16_t> +class _LIBCPP_TYPE_VIS __codecvt_utf8<char16_t> : public codecvt<char16_t, char, mbstate_t> { unsigned long _Maxcode_; @@ -143,7 +146,7 @@ protected: }; template <> -class __codecvt_utf8<char32_t> +class _LIBCPP_TYPE_VIS __codecvt_utf8<char32_t> : public codecvt<char32_t, char, mbstate_t> { unsigned long _Maxcode_; @@ -179,7 +182,7 @@ protected: template <class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = (codecvt_mode)0> -class _LIBCPP_TYPE_VIS codecvt_utf8 +class _LIBCPP_TYPE_VIS_ONLY codecvt_utf8 : public __codecvt_utf8<_Elem> { public: @@ -196,7 +199,7 @@ public: template <class _Elem, bool _LittleEndian> class __codecvt_utf16; template <> -class __codecvt_utf16<wchar_t, false> +class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, false> : public codecvt<wchar_t, char, mbstate_t> { unsigned long _Maxcode_; @@ -231,7 +234,7 @@ protected: }; template <> -class __codecvt_utf16<wchar_t, true> +class _LIBCPP_TYPE_VIS __codecvt_utf16<wchar_t, true> : public codecvt<wchar_t, char, mbstate_t> { unsigned long _Maxcode_; @@ -266,7 +269,7 @@ protected: }; template <> -class __codecvt_utf16<char16_t, false> +class _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, false> : public codecvt<char16_t, char, mbstate_t> { unsigned long _Maxcode_; @@ -301,7 +304,7 @@ protected: }; template <> -class __codecvt_utf16<char16_t, true> +class _LIBCPP_TYPE_VIS __codecvt_utf16<char16_t, true> : public codecvt<char16_t, char, mbstate_t> { unsigned long _Maxcode_; @@ -336,7 +339,7 @@ protected: }; template <> -class __codecvt_utf16<char32_t, false> +class _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, false> : public codecvt<char32_t, char, mbstate_t> { unsigned long _Maxcode_; @@ -371,7 +374,7 @@ protected: }; template <> -class __codecvt_utf16<char32_t, true> +class _LIBCPP_TYPE_VIS __codecvt_utf16<char32_t, true> : public codecvt<char32_t, char, mbstate_t> { unsigned long _Maxcode_; @@ -407,7 +410,7 @@ protected: template <class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = (codecvt_mode)0> -class _LIBCPP_TYPE_VIS codecvt_utf16 +class _LIBCPP_TYPE_VIS_ONLY codecvt_utf16 : public __codecvt_utf16<_Elem, _Mode & little_endian> { public: @@ -424,7 +427,7 @@ public: template <class _Elem> class __codecvt_utf8_utf16; template <> -class __codecvt_utf8_utf16<wchar_t> +class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<wchar_t> : public codecvt<wchar_t, char, mbstate_t> { unsigned long _Maxcode_; @@ -459,7 +462,7 @@ protected: }; template <> -class __codecvt_utf8_utf16<char32_t> +class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char32_t> : public codecvt<char32_t, char, mbstate_t> { unsigned long _Maxcode_; @@ -494,7 +497,7 @@ protected: }; template <> -class __codecvt_utf8_utf16<char16_t> +class _LIBCPP_TYPE_VIS __codecvt_utf8_utf16<char16_t> : public codecvt<char16_t, char, mbstate_t> { unsigned long _Maxcode_; @@ -530,7 +533,7 @@ protected: template <class _Elem, unsigned long _Maxcode = 0x10ffff, codecvt_mode _Mode = (codecvt_mode)0> -class _LIBCPP_TYPE_VIS codecvt_utf8_utf16 +class _LIBCPP_TYPE_VIS_ONLY codecvt_utf8_utf16 : public __codecvt_utf8_utf16<_Elem> { public: diff --git a/system/include/libcxx/complex b/system/include/libcxx/complex index dddc58e0..2943da1d 100644 --- a/system/include/libcxx/complex +++ b/system/include/libcxx/complex @@ -255,13 +255,13 @@ template<class T, class charT, class traits> _LIBCPP_BEGIN_NAMESPACE_STD -template<class _Tp> class _LIBCPP_TYPE_VIS complex; +template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY complex; template<class _Tp> complex<_Tp> operator*(const complex<_Tp>& __z, const complex<_Tp>& __w); template<class _Tp> complex<_Tp> operator/(const complex<_Tp>& __x, const complex<_Tp>& __y); template<class _Tp> -class _LIBCPP_TYPE_VIS complex +class _LIBCPP_TYPE_VIS_ONLY complex { public: typedef _Tp value_type; @@ -319,11 +319,11 @@ public: } }; -template<> class _LIBCPP_TYPE_VIS complex<double>; -template<> class _LIBCPP_TYPE_VIS complex<long double>; +template<> class _LIBCPP_TYPE_VIS_ONLY complex<double>; +template<> class _LIBCPP_TYPE_VIS_ONLY complex<long double>; template<> -class _LIBCPP_TYPE_VIS complex<float> +class _LIBCPP_TYPE_VIS_ONLY complex<float> { float __re_; float __im_; @@ -379,7 +379,7 @@ public: }; template<> -class _LIBCPP_TYPE_VIS complex<double> +class _LIBCPP_TYPE_VIS_ONLY complex<double> { double __re_; double __im_; @@ -435,7 +435,7 @@ public: }; template<> -class _LIBCPP_TYPE_VIS complex<long double> +class _LIBCPP_TYPE_VIS_ONLY complex<long double> { long double __re_; long double __im_; @@ -1521,6 +1521,47 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const complex<_Tp>& __x) return __os << __s.str(); } +#if _LIBCPP_STD_VER > 11 +// Literal suffix for complex number literals [complex.literals] +inline namespace literals +{ + inline namespace complex_literals + { + constexpr complex<long double> operator""il(long double __im) + { + return { 0.0l, __im }; + } + + constexpr complex<long double> operator""il(unsigned long long __im) + { + return { 0.0l, static_cast<long double>(__im) }; + } + + + constexpr complex<double> operator""i(long double __im) + { + return { 0.0, static_cast<double>(__im) }; + } + + constexpr complex<double> operator""i(unsigned long long __im) + { + return { 0.0, static_cast<double>(__im) }; + } + + + constexpr complex<float> operator""if(long double __im) + { + return { 0.0f, static_cast<float>(__im) }; + } + + constexpr complex<float> operator""if(unsigned long long __im) + { + return { 0.0f, static_cast<float>(__im) }; + } + } +} +#endif + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_COMPLEX diff --git a/system/include/libcxx/cstddef b/system/include/libcxx/cstddef index c2637721..7ef16ff2 100644 --- a/system/include/libcxx/cstddef +++ b/system/include/libcxx/cstddef @@ -56,7 +56,7 @@ typedef long double max_align_t; #ifdef _LIBCPP_HAS_NO_NULLPTR -struct _LIBCPP_TYPE_VIS nullptr_t +struct _LIBCPP_TYPE_VIS_ONLY nullptr_t { void* __lx; diff --git a/system/include/libcxx/cstdio b/system/include/libcxx/cstdio index 1cde3eee..ce3af4d9 100644 --- a/system/include/libcxx/cstdio +++ b/system/include/libcxx/cstdio @@ -74,7 +74,7 @@ int fputc(int c, FILE* stream); int fputs(const char* restrict s, FILE* restrict stream); int getc(FILE* stream); int getchar(void); -char* gets(char* s); +char* gets(char* s); // removed in C++14 int putc(int c, FILE* stream); int putchar(int c); int puts(const char* s); @@ -103,6 +103,11 @@ void perror(const char* s); #pragma GCC system_header #endif +// snprintf +#if defined(_LIBCPP_MSVCRT) +#include "support/win32/support.h" +#endif + #ifdef getc inline _LIBCPP_INLINE_VISIBILITY int __libcpp_getc(FILE* __stream) {return getc(__stream);} #undef getc @@ -153,7 +158,9 @@ using ::fputc; using ::fputs; using ::getc; using ::getchar; +#if _LIBCPP_STD_VER <= 11 using ::gets; +#endif using ::putc; using ::putchar; using ::puts; diff --git a/system/include/libcxx/cstdlib b/system/include/libcxx/cstdlib index 0a96fb0a..152b891d 100644 --- a/system/include/libcxx/cstdlib +++ b/system/include/libcxx/cstdlib @@ -155,7 +155,7 @@ using ::aligned_alloc; #endif // MSVCRT already has the correct prototype in <stdlib.h> #ifdef __cplusplus -#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) +#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX) inline _LIBCPP_INLINE_VISIBILITY long abs( long __x) _NOEXCEPT {return labs(__x);} #ifndef _LIBCPP_HAS_NO_LONG_LONG inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {return llabs(__x);} diff --git a/system/include/libcxx/cwchar b/system/include/libcxx/cwchar index 90eae75e..9f51587c 100644 --- a/system/include/libcxx/cwchar +++ b/system/include/libcxx/cwchar @@ -106,7 +106,7 @@ size_t wcsrtombs(char* restrict dst, const wchar_t** restrict src, size_t len, #include <__config> #include <cwctype> #include <wchar.h> -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) #include <support/win32/support.h> // pull in *swprintf defines #endif // _LIBCPP_MSVCRT diff --git a/system/include/libcxx/deque b/system/include/libcxx/deque index 86272721..f099000b 100644 --- a/system/include/libcxx/deque +++ b/system/include/libcxx/deque @@ -41,6 +41,7 @@ public: deque() noexcept(is_nothrow_default_constructible<allocator_type>::value); explicit deque(const allocator_type& a); explicit deque(size_type n); + explicit deque(size_type n, const allocator_type& a); // C++14 deque(size_type n, const value_type& v); deque(size_type n, const value_type& v, const allocator_type& a); template <class InputIterator> @@ -170,7 +171,7 @@ template <class _Tp, class _Allocator> class __deque_base; template <class _ValueType, class _Pointer, class _Reference, class _MapPointer, class _DiffType, _DiffType _BlockSize> -class _LIBCPP_TYPE_VIS __deque_iterator; +class _LIBCPP_TYPE_VIS_ONLY __deque_iterator; template <class _RAIter, class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2> @@ -262,7 +263,7 @@ move_backward(__deque_iterator<_V1, _P1, _R1, _M1, _D1, _B1> __f, template <class _ValueType, class _Pointer, class _Reference, class _MapPointer, class _DiffType, _DiffType _BlockSize> -class _LIBCPP_TYPE_VIS __deque_iterator +class _LIBCPP_TYPE_VIS_ONLY __deque_iterator { typedef _MapPointer __map_iterator; public: @@ -414,9 +415,9 @@ private: : __m_iter_(__m), __ptr_(__p) {} template <class _Tp, class _Ap> friend class __deque_base; - template <class _Tp, class _Ap> friend class _LIBCPP_TYPE_VIS deque; + template <class _Tp, class _Ap> friend class _LIBCPP_TYPE_VIS_ONLY deque; template <class _Vp, class _Pp, class _Rp, class _MP, class _Dp, _Dp> - friend class _LIBCPP_TYPE_VIS __deque_iterator; + friend class _LIBCPP_TYPE_VIS_ONLY __deque_iterator; template <class _RAIter, class _V2, class _P2, class _R2, class _M2, class _D2, _D2 _B2> @@ -1178,7 +1179,7 @@ __deque_base<_Tp, _Allocator>::clear() _NOEXCEPT } template <class _Tp, class _Allocator = allocator<_Tp> > -class _LIBCPP_TYPE_VIS deque +class _LIBCPP_TYPE_VIS_ONLY deque : private __deque_base<_Tp, _Allocator> { public: @@ -1209,6 +1210,9 @@ public: {} _LIBCPP_INLINE_VISIBILITY deque(const allocator_type& __a) : __base(__a) {} explicit deque(size_type __n); +#if _LIBCPP_STD_VER > 11 + explicit deque(size_type __n, const _Allocator& __a); +#endif deque(size_type __n, const value_type& __v); deque(size_type __n, const value_type& __v, const allocator_type& __a); template <class _InputIter> @@ -1431,6 +1435,16 @@ deque<_Tp, _Allocator>::deque(size_type __n) __append(__n); } +#if _LIBCPP_STD_VER > 11 +template <class _Tp, class _Allocator> +deque<_Tp, _Allocator>::deque(size_type __n, const _Allocator& __a) + : __base(__a) +{ + if (__n > 0) + __append(__n); +} +#endif + template <class _Tp, class _Allocator> deque<_Tp, _Allocator>::deque(size_type __n, const value_type& __v) { @@ -2797,7 +2811,7 @@ deque<_Tp, _Allocator>::clear() _NOEXCEPT } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator==(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) { @@ -2806,7 +2820,7 @@ operator==(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) { @@ -2814,7 +2828,7 @@ operator!=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator< (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) { @@ -2822,7 +2836,7 @@ operator< (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator> (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) { @@ -2830,7 +2844,7 @@ operator> (const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) { @@ -2838,7 +2852,7 @@ operator>=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) { @@ -2846,7 +2860,7 @@ operator<=(const deque<_Tp, _Allocator>& __x, const deque<_Tp, _Allocator>& __y) } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void swap(deque<_Tp, _Allocator>& __x, deque<_Tp, _Allocator>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) diff --git a/system/include/libcxx/dynarray b/system/include/libcxx/dynarray new file mode 100644 index 00000000..b0d04f91 --- /dev/null +++ b/system/include/libcxx/dynarray @@ -0,0 +1,311 @@ +// -*- C++ -*- +//===-------------------------- dynarray ----------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_DYNARRAY +#define _LIBCPP_DYNARRAY + +#include <__config> +#if _LIBCPP_STD_VER > 11 + +/* + dynarray synopsis + +namespace std { + +template< typename T > +class dynarray +{ + // types: + typedef T value_type; + typedef T& reference; + typedef const T& const_reference; + typedef T* pointer; + typedef const T* const_pointer; + typedef implementation-defined iterator; + typedef implementation-defined const_iterator; + typedef reverse_iterator<iterator> reverse_iterator; + typedef reverse_iterator<const_iterator> const_reverse_iterator; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + +public: + // construct/copy/destroy: + explicit dynarray(size_type c); + template <typename Alloc> + dynarray(size_type c, const Alloc& alloc); + dynarray(size_type c, const T& v); + template <typename Alloc> + dynarray(size_type c, const T& v, const Alloc& alloc); + dynarray(const dynarray& d); + template <typename Alloc> + dynarray(const dynarray& d, const Alloc& alloc); + dynarray(initializer_list<T>); + template <typename Alloc> + dynarray(initializer_list<T>, const Alloc& alloc); + + dynarray& operator=(const dynarray&) = delete; + ~dynarray(); + + // iterators: + iterator begin() noexcept; + const_iterator begin() const noexcept; + const_iterator cbegin() const noexcept; + iterator end() noexcept; + const_iterator end() const noexcept; + const_iterator cend() const noexcept; + + reverse_iterator rbegin() noexcept; + const_reverse_iterator rbegin() const noexcept; + const_reverse_iterator crbegin() const noexcept; + reverse_iterator rend() noexcept; + const_reverse_iterator rend() const noexcept; + const_reverse_iterator crend() const noexcept; + + // capacity: + size_type size() const noexcept; + size_type max_size() const noexcept; + bool empty() const noexcept; + + // element access: + reference operator[](size_type n); + const_reference operator[](size_type n) const; + + reference front(); + const_reference front() const; + reference back(); + const_reference back() const; + + const_reference at(size_type n) const; + reference at(size_type n); + + // data access: + T* data() noexcept; + const T* data() const noexcept; + + // mutating member functions: + void fill(const T& v); +}; + +} // std + +*/ + +#include <__functional_base> +#include <iterator> +#include <stdexcept> +#include <initializer_list> +#include <new> +#include <algorithm> + +#if defined(_LIBCPP_NO_EXCEPTIONS) + #include <cassert> +#endif + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +template <class _Tp> +struct _LIBCPP_TYPE_VIS_ONLY dynarray +{ +public: + // types: + typedef dynarray __self; + typedef _Tp value_type; + typedef value_type& reference; + typedef const value_type& const_reference; + typedef value_type* iterator; + typedef const value_type* const_iterator; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef std::reverse_iterator<iterator> reverse_iterator; + typedef std::reverse_iterator<const_iterator> const_reverse_iterator; + +private: + size_t __size_; + value_type * __base_; + _LIBCPP_ALWAYS_INLINE dynarray () noexcept : __base_(nullptr), __size_(0) {} + + static inline _LIBCPP_INLINE_VISIBILITY value_type* __allocate ( size_t count ) + { + if ( numeric_limits<size_t>::max() / sizeof (value_type) <= count ) + { +#ifndef _LIBCPP_NO_EXCEPTIONS + throw bad_array_length(); +#else + assert(!"dynarray::allocation"); +#endif + } + return static_cast<value_type *> (::operator new (sizeof(value_type) * count)); + } + + static inline _LIBCPP_INLINE_VISIBILITY void __deallocate ( value_type* __ptr ) noexcept + { + ::operator delete (static_cast<void *> (__ptr)); + } + +public: + + explicit dynarray(size_type __c); + dynarray(size_type __c, const value_type& __v); + dynarray(const dynarray& __d); + dynarray(initializer_list<value_type>); + +// We're not implementing these right now. +// Waiting for the resolution of LWG issue #2235 +// template <typename _Alloc> +// dynarray(size_type __c, const _Alloc& __alloc); +// template <typename _Alloc> +// dynarray(size_type __c, const value_type& __v, const _Alloc& __alloc); +// template <typename _Alloc> +// dynarray(const dynarray& __d, const _Alloc& __alloc); +// template <typename _Alloc> +// dynarray(initializer_list<value_type>, const _Alloc& __alloc); + + dynarray& operator=(const dynarray&) = delete; + ~dynarray(); + + // iterators: + inline _LIBCPP_INLINE_VISIBILITY iterator begin() noexcept { return iterator(data()); } + inline _LIBCPP_INLINE_VISIBILITY const_iterator begin() const noexcept { return const_iterator(data()); } + inline _LIBCPP_INLINE_VISIBILITY const_iterator cbegin() const noexcept { return const_iterator(data()); } + inline _LIBCPP_INLINE_VISIBILITY iterator end() noexcept { return iterator(data() + __size_); } + inline _LIBCPP_INLINE_VISIBILITY const_iterator end() const noexcept { return const_iterator(data() + __size_); } + inline _LIBCPP_INLINE_VISIBILITY const_iterator cend() const noexcept { return const_iterator(data() + __size_); } + + inline _LIBCPP_INLINE_VISIBILITY reverse_iterator rbegin() noexcept { return reverse_iterator(end()); } + inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rbegin() const noexcept { return const_reverse_iterator(end()); } + inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crbegin() const noexcept { return const_reverse_iterator(end()); } + inline _LIBCPP_INLINE_VISIBILITY reverse_iterator rend() noexcept { return reverse_iterator(begin()); } + inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator rend() const noexcept { return const_reverse_iterator(begin()); } + inline _LIBCPP_INLINE_VISIBILITY const_reverse_iterator crend() const noexcept { return const_reverse_iterator(begin()); } + + // capacity: + inline _LIBCPP_INLINE_VISIBILITY size_type size() const noexcept { return __size_; } + inline _LIBCPP_INLINE_VISIBILITY size_type max_size() const noexcept { return __size_; } + inline _LIBCPP_INLINE_VISIBILITY bool empty() const noexcept { return __size_ == 0; } + + // element access: + inline _LIBCPP_INLINE_VISIBILITY reference operator[](size_type __n) { return data()[__n]; } + inline _LIBCPP_INLINE_VISIBILITY const_reference operator[](size_type __n) const { return data()[__n]; } + + inline _LIBCPP_INLINE_VISIBILITY reference front() { return data()[0]; } + inline _LIBCPP_INLINE_VISIBILITY const_reference front() const { return data()[0]; } + inline _LIBCPP_INLINE_VISIBILITY reference back() { return data()[__size_-1]; } + inline _LIBCPP_INLINE_VISIBILITY const_reference back() const { return data()[__size_-1]; } + + inline _LIBCPP_INLINE_VISIBILITY const_reference at(size_type __n) const; + inline _LIBCPP_INLINE_VISIBILITY reference at(size_type __n); + + // data access: + inline _LIBCPP_INLINE_VISIBILITY _Tp* data() noexcept { return __base_; } + inline _LIBCPP_INLINE_VISIBILITY const _Tp* data() const noexcept { return __base_; } + + // mutating member functions: + inline _LIBCPP_INLINE_VISIBILITY void fill(const value_type& __v) { fill_n(begin(), __size_, __v); } +}; + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +dynarray<_Tp>::dynarray(size_type __c) : dynarray () +{ + __base_ = __allocate (__c); + value_type *__data = data (); + for ( __size_ = 0; __size_ < __c; ++__size_, ++__data ) + ::new (__data) value_type; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +dynarray<_Tp>::dynarray(size_type __c, const value_type& __v) : dynarray () +{ + __base_ = __allocate (__c); + value_type *__data = data (); + for ( __size_ = 0; __size_ < __c; ++__size_, ++__data ) + ::new (__data) value_type (__v); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +dynarray<_Tp>::dynarray(initializer_list<value_type> __il) : dynarray () +{ + size_t sz = __il.size(); + __base_ = __allocate (sz); + value_type *__data = data (); + auto src = __il.begin(); + for ( __size_ = 0; __size_ < sz; ++__size_, ++__data, ++src ) + ::new (__data) value_type (*src); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +dynarray<_Tp>::dynarray(const dynarray& __d) : dynarray () +{ + size_t sz = __d.size(); + __base_ = __allocate (sz); + value_type *__data = data (); + auto src = __d.begin(); + for ( __size_ = 0; __size_ < sz; ++__size_, ++__data, ++src ) + ::new (__data) value_type (*src); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +dynarray<_Tp>::~dynarray() +{ + value_type *__data = data () + __size_; + for ( size_t i = 0; i < __size_; ++i ) + (--__data)->value_type::~value_type(); + __deallocate ( __base_ ); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +typename dynarray<_Tp>::reference +dynarray<_Tp>::at(size_type __n) +{ + if (__n >= __size_) + { +#ifndef _LIBCPP_NO_EXCEPTIONS + throw out_of_range("dynarray::at"); +#else + assert(!"dynarray::at out_of_range"); +#endif + } + return data()[__n]; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +typename dynarray<_Tp>::const_reference +dynarray<_Tp>::at(size_type __n) const +{ + if (__n >= __size_) + { +#ifndef _LIBCPP_NO_EXCEPTIONS + throw out_of_range("dynarray::at"); +#else + assert(!"dynarray::at out_of_range"); +#endif + } + return data()[__n]; +} + +template <class _Tp, class _Alloc> +struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<dynarray<_Tp>, _Alloc> : true_type {}; + +_LIBCPP_END_NAMESPACE_STD + +#endif // if _LIBCPP_STD_VER > 11 +#endif // _LIBCPP_DYNARRAY diff --git a/system/include/libcxx/exception b/system/include/libcxx/exception index 102b10d6..ddd75bd4 100644 --- a/system/include/libcxx/exception +++ b/system/include/libcxx/exception @@ -118,8 +118,8 @@ _LIBCPP_FUNC_VIS bool uncaught_exception() _NOEXCEPT; class _LIBCPP_TYPE_VIS exception_ptr; -exception_ptr current_exception() _NOEXCEPT; -_LIBCPP_NORETURN void rethrow_exception(exception_ptr); +_LIBCPP_FUNC_VIS exception_ptr current_exception() _NOEXCEPT; +_LIBCPP_NORETURN _LIBCPP_FUNC_VIS void rethrow_exception(exception_ptr); class _LIBCPP_TYPE_VIS exception_ptr { @@ -142,8 +142,8 @@ public: bool operator!=(const exception_ptr& __x, const exception_ptr& __y) _NOEXCEPT {return !(__x == __y);} - friend exception_ptr current_exception() _NOEXCEPT; - friend void rethrow_exception(exception_ptr); + friend _LIBCPP_FUNC_VIS exception_ptr current_exception() _NOEXCEPT; + friend _LIBCPP_FUNC_VIS void rethrow_exception(exception_ptr); }; template<class _Ep> diff --git a/system/include/libcxx/ext/__hash b/system/include/libcxx/ext/__hash index f6ecfe36..04975bfd 100644 --- a/system/include/libcxx/ext/__hash +++ b/system/include/libcxx/ext/__hash @@ -19,10 +19,10 @@ namespace __gnu_cxx { using namespace std; -template <typename T> struct _LIBCPP_TYPE_VIS hash : public std::hash<T> +template <typename T> struct _LIBCPP_TYPE_VIS_ONLY hash : public std::hash<T> { }; -template <> struct _LIBCPP_TYPE_VIS hash<const char*> +template <> struct _LIBCPP_TYPE_VIS_ONLY hash<const char*> : public unary_function<const char*, size_t> { _LIBCPP_INLINE_VISIBILITY @@ -32,7 +32,7 @@ template <> struct _LIBCPP_TYPE_VIS hash<const char*> } }; -template <> struct _LIBCPP_TYPE_VIS hash<char *> +template <> struct _LIBCPP_TYPE_VIS_ONLY hash<char *> : public unary_function<char*, size_t> { _LIBCPP_INLINE_VISIBILITY diff --git a/system/include/libcxx/ext/hash_map b/system/include/libcxx/ext/hash_map index a6fe894e..225b72ba 100644 --- a/system/include/libcxx/ext/hash_map +++ b/system/include/libcxx/ext/hash_map @@ -206,7 +206,11 @@ template <class Key, class T, class Hash, class Pred, class Alloc> #include <ext/__hash> #if __DEPRECATED -#warning Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map> +#if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map>") +#else +# warning Use of the header <ext/hash_map> is deprecated. Migrate to <unordered_map> +#endif #endif #pragma GCC system_header @@ -361,7 +365,7 @@ public: }; template <class _HashIterator> -class _LIBCPP_TYPE_VIS __hash_map_iterator +class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator { _HashIterator __i_; @@ -404,15 +408,15 @@ public: bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y) {return __x.__i_ != __y.__i_;} - template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS hash_map; - template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS hash_multimap; - template <class> friend class _LIBCPP_TYPE_VIS __hash_const_iterator; - template <class> friend class _LIBCPP_TYPE_VIS __hash_const_local_iterator; - template <class> friend class _LIBCPP_TYPE_VIS __hash_map_const_iterator; + template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY hash_map; + template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY hash_multimap; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator; }; template <class _HashIterator> -class _LIBCPP_TYPE_VIS __hash_map_const_iterator +class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator { _HashIterator __i_; @@ -463,15 +467,15 @@ public: bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y) {return __x.__i_ != __y.__i_;} - template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS hash_map; - template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS hash_multimap; - template <class> friend class _LIBCPP_TYPE_VIS __hash_const_iterator; - template <class> friend class _LIBCPP_TYPE_VIS __hash_const_local_iterator; + template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY hash_map; + template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY hash_multimap; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator; }; template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>, class _Alloc = allocator<pair<const _Key, _Tp> > > -class _LIBCPP_TYPE_VIS hash_map +class _LIBCPP_TYPE_VIS_ONLY hash_map { public: // types @@ -684,7 +688,7 @@ hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node(const key_type& __k) __h.get_deleter().__first_constructed = true; __node_traits::construct(__na, _VSTD::addressof(__h->__value_.second)); __h.get_deleter().__second_constructed = true; - return _VSTD::move(__h); + return _VSTD::move(__h); // explicitly moved for C++03 } template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> @@ -750,7 +754,7 @@ operator!=(const hash_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>, class _Alloc = allocator<pair<const _Key, _Tp> > > -class _LIBCPP_TYPE_VIS hash_multimap +class _LIBCPP_TYPE_VIS_ONLY hash_multimap { public: // types diff --git a/system/include/libcxx/ext/hash_set b/system/include/libcxx/ext/hash_set index 52bbeee1..c4bb8984 100644 --- a/system/include/libcxx/ext/hash_set +++ b/system/include/libcxx/ext/hash_set @@ -199,7 +199,11 @@ template <class Value, class Hash, class Pred, class Alloc> #include <ext/__hash> #if __DEPRECATED -#warning Use of the header <ext/hash_set> is deprecated. Migrate to <unordered_set> +#if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("Use of the header <ext/hash_set> is deprecated. Migrate to <unordered_set>") +#else +# warning Use of the header <ext/hash_set> is deprecated. Migrate to <unordered_set> +#endif #endif namespace __gnu_cxx { @@ -208,7 +212,7 @@ using namespace std; template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, class _Alloc = allocator<_Value> > -class _LIBCPP_TYPE_VIS hash_set +class _LIBCPP_TYPE_VIS_ONLY hash_set { public: // types @@ -429,7 +433,7 @@ operator!=(const hash_set<_Value, _Hash, _Pred, _Alloc>& __x, template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, class _Alloc = allocator<_Value> > -class _LIBCPP_TYPE_VIS hash_multiset +class _LIBCPP_TYPE_VIS_ONLY hash_multiset { public: // types diff --git a/system/include/libcxx/forward_list b/system/include/libcxx/forward_list index 88bf75f9..398226b8 100644 --- a/system/include/libcxx/forward_list +++ b/system/include/libcxx/forward_list @@ -38,6 +38,7 @@ public: noexcept(is_nothrow_default_constructible<allocator_type>::value); explicit forward_list(const allocator_type& a); explicit forward_list(size_type n); + explicit forward_list(size_type n, const allocator_type& a); // C++14 forward_list(size_type n, const value_type& v); forward_list(size_type n, const value_type& v, const allocator_type& a); template <class InputIterator> @@ -212,11 +213,11 @@ struct __forward_list_node value_type __value_; }; -template<class _Tp, class _Alloc> class _LIBCPP_TYPE_VIS forward_list; -template<class _NodeConstPtr> class _LIBCPP_TYPE_VIS __forward_list_const_iterator; +template<class _Tp, class _Alloc> class _LIBCPP_TYPE_VIS_ONLY forward_list; +template<class _NodeConstPtr> class _LIBCPP_TYPE_VIS_ONLY __forward_list_const_iterator; template <class _NodePtr> -class _LIBCPP_TYPE_VIS __forward_list_iterator +class _LIBCPP_TYPE_VIS_ONLY __forward_list_iterator { typedef _NodePtr __node_pointer; @@ -225,8 +226,8 @@ class _LIBCPP_TYPE_VIS __forward_list_iterator _LIBCPP_INLINE_VISIBILITY explicit __forward_list_iterator(__node_pointer __p) _NOEXCEPT : __ptr_(__p) {} - template<class, class> friend class _LIBCPP_TYPE_VIS forward_list; - template<class> friend class _LIBCPP_TYPE_VIS __forward_list_const_iterator; + template<class, class> friend class _LIBCPP_TYPE_VIS_ONLY forward_list; + template<class> friend class _LIBCPP_TYPE_VIS_ONLY __forward_list_const_iterator; public: typedef forward_iterator_tag iterator_category; @@ -276,7 +277,7 @@ public: }; template <class _NodeConstPtr> -class _LIBCPP_TYPE_VIS __forward_list_const_iterator +class _LIBCPP_TYPE_VIS_ONLY __forward_list_const_iterator { typedef _NodeConstPtr __node_const_pointer; @@ -542,7 +543,7 @@ __forward_list_base<_Tp, _Alloc>::clear() _NOEXCEPT } template <class _Tp, class _Alloc = allocator<_Tp> > -class _LIBCPP_TYPE_VIS forward_list +class _LIBCPP_TYPE_VIS_ONLY forward_list : private __forward_list_base<_Tp, _Alloc> { typedef __forward_list_base<_Tp, _Alloc> base; @@ -571,6 +572,9 @@ public: {} // = default; explicit forward_list(const allocator_type& __a); explicit forward_list(size_type __n); +#if _LIBCPP_STD_VER > 11 + explicit forward_list(size_type __n, const allocator_type& __a); +#endif forward_list(size_type __n, const value_type& __v); forward_list(size_type __n, const value_type& __v, const allocator_type& __a); template <class _InputIterator> @@ -794,6 +798,28 @@ forward_list<_Tp, _Alloc>::forward_list(size_type __n) } } +#if _LIBCPP_STD_VER > 11 +template <class _Tp, class _Alloc> +forward_list<_Tp, _Alloc>::forward_list(size_type __n, const allocator_type& __a) + : base ( __a ) +{ + if (__n > 0) + { + __node_allocator& __a = base::__alloc(); + typedef __allocator_destructor<__node_allocator> _Dp; + unique_ptr<__node, _Dp> __h(nullptr, _Dp(__a, 1)); + for (__node_pointer __p = base::__before_begin(); __n > 0; --__n, + __p = __p->__next_) + { + __h.reset(__node_traits::allocate(__a, 1)); + __node_traits::construct(__a, _VSTD::addressof(__h->__value_)); + __h->__next_ = nullptr; + __p->__next_ = __h.release(); + } + } +} +#endif + template <class _Tp, class _Alloc> forward_list<_Tp, _Alloc>::forward_list(size_type __n, const value_type& __v) { diff --git a/system/include/libcxx/fstream b/system/include/libcxx/fstream index e3f8306f..38778c67 100644 --- a/system/include/libcxx/fstream +++ b/system/include/libcxx/fstream @@ -180,7 +180,7 @@ typedef basic_fstream<wchar_t> wfstream; _LIBCPP_BEGIN_NAMESPACE_STD template <class _CharT, class _Traits> -class _LIBCPP_TYPE_VIS basic_filebuf +class _LIBCPP_TYPE_VIS_ONLY basic_filebuf : public basic_streambuf<_CharT, _Traits> { public: @@ -994,7 +994,7 @@ basic_filebuf<_CharT, _Traits>::__write_mode() // basic_ifstream template <class _CharT, class _Traits> -class _LIBCPP_TYPE_VIS basic_ifstream +class _LIBCPP_TYPE_VIS_ONLY basic_ifstream : public basic_istream<_CharT, _Traits> { public: @@ -1139,7 +1139,7 @@ basic_ifstream<_CharT, _Traits>::close() // basic_ofstream template <class _CharT, class _Traits> -class _LIBCPP_TYPE_VIS basic_ofstream +class _LIBCPP_TYPE_VIS_ONLY basic_ofstream : public basic_ostream<_CharT, _Traits> { public: @@ -1284,7 +1284,7 @@ basic_ofstream<_CharT, _Traits>::close() // basic_fstream template <class _CharT, class _Traits> -class _LIBCPP_TYPE_VIS basic_fstream +class _LIBCPP_TYPE_VIS_ONLY basic_fstream : public basic_iostream<_CharT, _Traits> { public: diff --git a/system/include/libcxx/functional b/system/include/libcxx/functional index 2130f0e3..d40f70af 100644 --- a/system/include/libcxx/functional +++ b/system/include/libcxx/functional @@ -56,7 +56,7 @@ public: // invoke template <class... ArgTypes> - typename result_of<T(ArgTypes...)>::type + typename result_of<T&(ArgTypes&&...)>::type operator() (ArgTypes&&...) const; }; @@ -358,18 +358,6 @@ template <class S, class T> const_mem_fun_ref_t<S,T> mem_fun_ref(S ( template <class S, class T, class A> const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const); template<class R, class T> unspecified mem_fn(R T::*); -template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...)); -template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const); -template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) volatile); -template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const volatile); -template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) &); -template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const &); -template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) volatile &); -template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const volatile &); -template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) &&); -template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const &&); -template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) volatile &&); -template<class R, class T, class... Args> unspecified mem_fn(R (T::*)(Args...) const volatile &&); class bad_function_call : public exception @@ -502,19 +490,22 @@ template <class _Tp = void> #else template <class _Tp> #endif -struct _LIBCPP_TYPE_VIS plus : binary_function<_Tp, _Tp, _Tp> +struct _LIBCPP_TYPE_VIS_ONLY plus : binary_function<_Tp, _Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x + __y;} }; #if _LIBCPP_STD_VER > 11 template <> -struct _LIBCPP_TYPE_VIS plus<void> +struct _LIBCPP_TYPE_VIS_ONLY plus<void> { template <class _T1, class _T2> - _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); } + typedef void is_transparent; }; #endif @@ -524,19 +515,22 @@ template <class _Tp = void> #else template <class _Tp> #endif -struct _LIBCPP_TYPE_VIS minus : binary_function<_Tp, _Tp, _Tp> +struct _LIBCPP_TYPE_VIS_ONLY minus : binary_function<_Tp, _Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x - __y;} }; #if _LIBCPP_STD_VER > 11 template <> -struct _LIBCPP_TYPE_VIS minus<void> +struct _LIBCPP_TYPE_VIS_ONLY minus<void> { template <class _T1, class _T2> - _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); } + typedef void is_transparent; }; #endif @@ -546,19 +540,22 @@ template <class _Tp = void> #else template <class _Tp> #endif -struct _LIBCPP_TYPE_VIS multiplies : binary_function<_Tp, _Tp, _Tp> +struct _LIBCPP_TYPE_VIS_ONLY multiplies : binary_function<_Tp, _Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x * __y;} }; #if _LIBCPP_STD_VER > 11 template <> -struct _LIBCPP_TYPE_VIS multiplies<void> +struct _LIBCPP_TYPE_VIS_ONLY multiplies<void> { template <class _T1, class _T2> - _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); } + typedef void is_transparent; }; #endif @@ -568,19 +565,22 @@ template <class _Tp = void> #else template <class _Tp> #endif -struct _LIBCPP_TYPE_VIS divides : binary_function<_Tp, _Tp, _Tp> +struct _LIBCPP_TYPE_VIS_ONLY divides : binary_function<_Tp, _Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x / __y;} }; #if _LIBCPP_STD_VER > 11 template <> -struct _LIBCPP_TYPE_VIS divides<void> +struct _LIBCPP_TYPE_VIS_ONLY divides<void> { template <class _T1, class _T2> - _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); } + typedef void is_transparent; }; #endif @@ -590,19 +590,22 @@ template <class _Tp = void> #else template <class _Tp> #endif -struct _LIBCPP_TYPE_VIS modulus : binary_function<_Tp, _Tp, _Tp> +struct _LIBCPP_TYPE_VIS_ONLY modulus : binary_function<_Tp, _Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x % __y;} }; #if _LIBCPP_STD_VER > 11 template <> -struct _LIBCPP_TYPE_VIS modulus<void> +struct _LIBCPP_TYPE_VIS_ONLY modulus<void> { template <class _T1, class _T2> - _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); } + typedef void is_transparent; }; #endif @@ -612,19 +615,22 @@ template <class _Tp = void> #else template <class _Tp> #endif -struct _LIBCPP_TYPE_VIS negate : unary_function<_Tp, _Tp> +struct _LIBCPP_TYPE_VIS_ONLY negate : unary_function<_Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x) const {return -__x;} }; #if _LIBCPP_STD_VER > 11 template <> -struct _LIBCPP_TYPE_VIS negate<void> +struct _LIBCPP_TYPE_VIS_ONLY negate<void> { template <class _Tp> - _LIBCPP_INLINE_VISIBILITY auto operator()(_Tp&& __x) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_Tp&& __x) const { return -_VSTD::forward<_Tp>(__x); } + typedef void is_transparent; }; #endif @@ -634,19 +640,22 @@ template <class _Tp = void> #else template <class _Tp> #endif -struct _LIBCPP_TYPE_VIS equal_to : binary_function<_Tp, _Tp, bool> +struct _LIBCPP_TYPE_VIS_ONLY equal_to : binary_function<_Tp, _Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const {return __x == __y;} }; #if _LIBCPP_STD_VER > 11 template <> -struct _LIBCPP_TYPE_VIS equal_to<void> +struct _LIBCPP_TYPE_VIS_ONLY equal_to<void> { - template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY + template <class _T1, class _T2> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); } + typedef void is_transparent; }; #endif @@ -656,19 +665,22 @@ template <class _Tp = void> #else template <class _Tp> #endif -struct _LIBCPP_TYPE_VIS not_equal_to : binary_function<_Tp, _Tp, bool> +struct _LIBCPP_TYPE_VIS_ONLY not_equal_to : binary_function<_Tp, _Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const {return __x != __y;} }; #if _LIBCPP_STD_VER > 11 template <> -struct _LIBCPP_TYPE_VIS not_equal_to<void> +struct _LIBCPP_TYPE_VIS_ONLY not_equal_to<void> { - template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY + template <class _T1, class _T2> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); } + typedef void is_transparent; }; #endif @@ -678,19 +690,22 @@ template <class _Tp = void> #else template <class _Tp> #endif -struct _LIBCPP_TYPE_VIS greater : binary_function<_Tp, _Tp, bool> +struct _LIBCPP_TYPE_VIS_ONLY greater : binary_function<_Tp, _Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const {return __x > __y;} }; #if _LIBCPP_STD_VER > 11 template <> -struct _LIBCPP_TYPE_VIS greater<void> +struct _LIBCPP_TYPE_VIS_ONLY greater<void> { - template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY + template <class _T1, class _T2> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); } + typedef void is_transparent; }; #endif @@ -702,19 +717,22 @@ template <class _Tp = void> #else template <class _Tp> #endif -struct _LIBCPP_TYPE_VIS greater_equal : binary_function<_Tp, _Tp, bool> +struct _LIBCPP_TYPE_VIS_ONLY greater_equal : binary_function<_Tp, _Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const {return __x >= __y;} }; #if _LIBCPP_STD_VER > 11 template <> -struct _LIBCPP_TYPE_VIS greater_equal<void> +struct _LIBCPP_TYPE_VIS_ONLY greater_equal<void> { - template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY + template <class _T1, class _T2> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); } + typedef void is_transparent; }; #endif @@ -724,19 +742,22 @@ template <class _Tp = void> #else template <class _Tp> #endif -struct _LIBCPP_TYPE_VIS less_equal : binary_function<_Tp, _Tp, bool> +struct _LIBCPP_TYPE_VIS_ONLY less_equal : binary_function<_Tp, _Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const {return __x <= __y;} }; #if _LIBCPP_STD_VER > 11 template <> -struct _LIBCPP_TYPE_VIS less_equal<void> +struct _LIBCPP_TYPE_VIS_ONLY less_equal<void> { - template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY + template <class _T1, class _T2> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); } + typedef void is_transparent; }; #endif @@ -746,19 +767,22 @@ template <class _Tp = void> #else template <class _Tp> #endif -struct _LIBCPP_TYPE_VIS logical_and : binary_function<_Tp, _Tp, bool> +struct _LIBCPP_TYPE_VIS_ONLY logical_and : binary_function<_Tp, _Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const {return __x && __y;} }; #if _LIBCPP_STD_VER > 11 template <> -struct _LIBCPP_TYPE_VIS logical_and<void> +struct _LIBCPP_TYPE_VIS_ONLY logical_and<void> { - template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY + template <class _T1, class _T2> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); } + typedef void is_transparent; }; #endif @@ -768,19 +792,22 @@ template <class _Tp = void> #else template <class _Tp> #endif -struct _LIBCPP_TYPE_VIS logical_or : binary_function<_Tp, _Tp, bool> +struct _LIBCPP_TYPE_VIS_ONLY logical_or : binary_function<_Tp, _Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x, const _Tp& __y) const {return __x || __y;} }; #if _LIBCPP_STD_VER > 11 template <> -struct _LIBCPP_TYPE_VIS logical_or<void> +struct _LIBCPP_TYPE_VIS_ONLY logical_or<void> { - template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY + template <class _T1, class _T2> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); } + typedef void is_transparent; }; #endif @@ -790,19 +817,22 @@ template <class _Tp = void> #else template <class _Tp> #endif -struct _LIBCPP_TYPE_VIS logical_not : unary_function<_Tp, bool> +struct _LIBCPP_TYPE_VIS_ONLY logical_not : unary_function<_Tp, bool> { - _LIBCPP_INLINE_VISIBILITY bool operator()(const _Tp& __x) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const _Tp& __x) const {return !__x;} }; #if _LIBCPP_STD_VER > 11 template <> -struct _LIBCPP_TYPE_VIS logical_not<void> +struct _LIBCPP_TYPE_VIS_ONLY logical_not<void> { template <class _Tp> - _LIBCPP_INLINE_VISIBILITY auto operator()(_Tp&& __x) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_Tp&& __x) const { return !_VSTD::forward<_Tp>(__x); } + typedef void is_transparent; }; #endif @@ -812,19 +842,22 @@ template <class _Tp = void> #else template <class _Tp> #endif -struct _LIBCPP_TYPE_VIS bit_and : binary_function<_Tp, _Tp, _Tp> +struct _LIBCPP_TYPE_VIS_ONLY bit_and : binary_function<_Tp, _Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x & __y;} }; #if _LIBCPP_STD_VER > 11 template <> -struct _LIBCPP_TYPE_VIS bit_and<void> +struct _LIBCPP_TYPE_VIS_ONLY bit_and<void> { - template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY + template <class _T1, class _T2> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); } + typedef void is_transparent; }; #endif @@ -834,19 +867,22 @@ template <class _Tp = void> #else template <class _Tp> #endif -struct _LIBCPP_TYPE_VIS bit_or : binary_function<_Tp, _Tp, _Tp> +struct _LIBCPP_TYPE_VIS_ONLY bit_or : binary_function<_Tp, _Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x | __y;} }; #if _LIBCPP_STD_VER > 11 template <> -struct _LIBCPP_TYPE_VIS bit_or<void> +struct _LIBCPP_TYPE_VIS_ONLY bit_or<void> { - template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY + template <class _T1, class _T2> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); } + typedef void is_transparent; }; #endif @@ -856,79 +892,89 @@ template <class _Tp = void> #else template <class _Tp> #endif -struct _LIBCPP_TYPE_VIS bit_xor : binary_function<_Tp, _Tp, _Tp> +struct _LIBCPP_TYPE_VIS_ONLY bit_xor : binary_function<_Tp, _Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x, const _Tp& __y) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x, const _Tp& __y) const {return __x ^ __y;} }; #if _LIBCPP_STD_VER > 11 template <> -struct _LIBCPP_TYPE_VIS bit_xor<void> +struct _LIBCPP_TYPE_VIS_ONLY bit_xor<void> { - template <class _T1, class _T2> _LIBCPP_INLINE_VISIBILITY + template <class _T1, class _T2> + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY auto operator()(_T1&& __t, _T2&& __u) const { return _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u); } + typedef void is_transparent; }; #endif #if _LIBCPP_STD_VER > 11 template <class _Tp = void> -struct _LIBCPP_TYPE_VIS bit_not : unary_function<_Tp, _Tp> +struct _LIBCPP_TYPE_VIS_ONLY bit_not : unary_function<_Tp, _Tp> { - _LIBCPP_INLINE_VISIBILITY _Tp operator()(const _Tp& __x) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + _Tp operator()(const _Tp& __x) const {return ~__x;} }; template <> -struct _LIBCPP_TYPE_VIS bit_not<void> +struct _LIBCPP_TYPE_VIS_ONLY bit_not<void> { template <class _Tp> - _LIBCPP_INLINE_VISIBILITY auto operator()(_Tp&& __x) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + auto operator()(_Tp&& __x) const { return ~_VSTD::forward<_Tp>(__x); } + typedef void is_transparent; }; #endif template <class _Predicate> -class _LIBCPP_TYPE_VIS unary_negate +class _LIBCPP_TYPE_VIS_ONLY unary_negate : public unary_function<typename _Predicate::argument_type, bool> { _Predicate __pred_; public: - _LIBCPP_INLINE_VISIBILITY explicit unary_negate(const _Predicate& __pred) + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + explicit unary_negate(const _Predicate& __pred) : __pred_(__pred) {} - _LIBCPP_INLINE_VISIBILITY bool operator()(const typename _Predicate::argument_type& __x) const + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const typename _Predicate::argument_type& __x) const {return !__pred_(__x);} }; template <class _Predicate> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY unary_negate<_Predicate> not1(const _Predicate& __pred) {return unary_negate<_Predicate>(__pred);} template <class _Predicate> -class _LIBCPP_TYPE_VIS binary_negate +class _LIBCPP_TYPE_VIS_ONLY binary_negate : public binary_function<typename _Predicate::first_argument_type, typename _Predicate::second_argument_type, bool> { _Predicate __pred_; public: - _LIBCPP_INLINE_VISIBILITY explicit binary_negate(const _Predicate& __pred) - : __pred_(__pred) {} - _LIBCPP_INLINE_VISIBILITY bool operator()(const typename _Predicate::first_argument_type& __x, + _LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_AFTER_CXX11 + binary_negate(const _Predicate& __pred) : __pred_(__pred) {} + + _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY + bool operator()(const typename _Predicate::first_argument_type& __x, const typename _Predicate::second_argument_type& __y) const {return !__pred_(__x, __y);} }; template <class _Predicate> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_CONSTEXPR_AFTER_CXX11 _LIBCPP_INLINE_VISIBILITY binary_negate<_Predicate> not2(const _Predicate& __pred) {return binary_negate<_Predicate>(__pred);} template <class __Operation> -class _LIBCPP_TYPE_VIS binder1st +class _LIBCPP_TYPE_VIS_ONLY binder1st : public unary_function<typename __Operation::second_argument_type, typename __Operation::result_type> { @@ -954,7 +1000,7 @@ bind1st(const __Operation& __op, const _Tp& __x) {return binder1st<__Operation>(__op, __x);} template <class __Operation> -class _LIBCPP_TYPE_VIS binder2nd +class _LIBCPP_TYPE_VIS_ONLY binder2nd : public unary_function<typename __Operation::first_argument_type, typename __Operation::result_type> { @@ -980,7 +1026,7 @@ bind2nd(const __Operation& __op, const _Tp& __x) {return binder2nd<__Operation>(__op, __x);} template <class _Arg, class _Result> -class _LIBCPP_TYPE_VIS pointer_to_unary_function +class _LIBCPP_TYPE_VIS_ONLY pointer_to_unary_function : public unary_function<_Arg, _Result> { _Result (*__f_)(_Arg); @@ -998,7 +1044,7 @@ ptr_fun(_Result (*__f)(_Arg)) {return pointer_to_unary_function<_Arg,_Result>(__f);} template <class _Arg1, class _Arg2, class _Result> -class _LIBCPP_TYPE_VIS pointer_to_binary_function +class _LIBCPP_TYPE_VIS_ONLY pointer_to_binary_function : public binary_function<_Arg1, _Arg2, _Result> { _Result (*__f_)(_Arg1, _Arg2); @@ -1016,7 +1062,7 @@ ptr_fun(_Result (*__f)(_Arg1,_Arg2)) {return pointer_to_binary_function<_Arg1,_Arg2,_Result>(__f);} template<class _Sp, class _Tp> -class _LIBCPP_TYPE_VIS mem_fun_t : public unary_function<_Tp*, _Sp> +class _LIBCPP_TYPE_VIS_ONLY mem_fun_t : public unary_function<_Tp*, _Sp> { _Sp (_Tp::*__p_)(); public: @@ -1027,7 +1073,7 @@ public: }; template<class _Sp, class _Tp, class _Ap> -class _LIBCPP_TYPE_VIS mem_fun1_t : public binary_function<_Tp*, _Ap, _Sp> +class _LIBCPP_TYPE_VIS_ONLY mem_fun1_t : public binary_function<_Tp*, _Ap, _Sp> { _Sp (_Tp::*__p_)(_Ap); public: @@ -1050,7 +1096,7 @@ mem_fun(_Sp (_Tp::*__f)(_Ap)) {return mem_fun1_t<_Sp,_Tp,_Ap>(__f);} template<class _Sp, class _Tp> -class _LIBCPP_TYPE_VIS mem_fun_ref_t : public unary_function<_Tp, _Sp> +class _LIBCPP_TYPE_VIS_ONLY mem_fun_ref_t : public unary_function<_Tp, _Sp> { _Sp (_Tp::*__p_)(); public: @@ -1061,7 +1107,7 @@ public: }; template<class _Sp, class _Tp, class _Ap> -class _LIBCPP_TYPE_VIS mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp> +class _LIBCPP_TYPE_VIS_ONLY mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp> { _Sp (_Tp::*__p_)(_Ap); public: @@ -1084,7 +1130,7 @@ mem_fun_ref(_Sp (_Tp::*__f)(_Ap)) {return mem_fun1_ref_t<_Sp,_Tp,_Ap>(__f);} template <class _Sp, class _Tp> -class _LIBCPP_TYPE_VIS const_mem_fun_t : public unary_function<const _Tp*, _Sp> +class _LIBCPP_TYPE_VIS_ONLY const_mem_fun_t : public unary_function<const _Tp*, _Sp> { _Sp (_Tp::*__p_)() const; public: @@ -1095,7 +1141,7 @@ public: }; template <class _Sp, class _Tp, class _Ap> -class _LIBCPP_TYPE_VIS const_mem_fun1_t : public binary_function<const _Tp*, _Ap, _Sp> +class _LIBCPP_TYPE_VIS_ONLY const_mem_fun1_t : public binary_function<const _Tp*, _Ap, _Sp> { _Sp (_Tp::*__p_)(_Ap) const; public: @@ -1118,7 +1164,7 @@ mem_fun(_Sp (_Tp::*__f)(_Ap) const) {return const_mem_fun1_t<_Sp,_Tp,_Ap>(__f);} template <class _Sp, class _Tp> -class _LIBCPP_TYPE_VIS const_mem_fun_ref_t : public unary_function<_Tp, _Sp> +class _LIBCPP_TYPE_VIS_ONLY const_mem_fun_ref_t : public unary_function<_Tp, _Sp> { _Sp (_Tp::*__p_)() const; public: @@ -1129,7 +1175,7 @@ public: }; template <class _Sp, class _Tp, class _Ap> -class _LIBCPP_TYPE_VIS const_mem_fun1_ref_t +class _LIBCPP_TYPE_VIS_ONLY const_mem_fun1_ref_t : public binary_function<_Tp, _Ap, _Sp> { _Sp (_Tp::*__p_)(_Ap) const; @@ -1189,38 +1235,6 @@ mem_fn(_Rp _Tp::* __pm) return __mem_fn<_Rp _Tp::*>(__pm); } -template<class _Rp, class _Tp, class ..._Args> -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_Args...)> -mem_fn(_Rp (_Tp::* __pm)(_Args...)) -{ - return __mem_fn<_Rp (_Tp::*)(_Args...)>(__pm); -} - -template<class _Rp, class _Tp, class ..._Args> -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_Args...) const> -mem_fn(_Rp (_Tp::* __pm)(_Args...) const) -{ - return __mem_fn<_Rp (_Tp::*)(_Args...) const>(__pm); -} - -template<class _Rp, class _Tp, class ..._Args> -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_Args...) volatile> -mem_fn(_Rp (_Tp::* __pm)(_Args...) volatile) -{ - return __mem_fn<_Rp (_Tp::*)(_Args...) volatile>(__pm); -} - -template<class _Rp, class _Tp, class ..._Args> -inline _LIBCPP_INLINE_VISIBILITY -__mem_fn<_Rp (_Tp::*)(_Args...) const volatile> -mem_fn(_Rp (_Tp::* __pm)(_Args...) const volatile) -{ - return __mem_fn<_Rp (_Tp::*)(_Args...) const volatile>(__pm); -} - // bad_function_call class _LIBCPP_EXCEPTION_ABI bad_function_call @@ -1228,7 +1242,7 @@ class _LIBCPP_EXCEPTION_ABI bad_function_call { }; -template<class _Fp> class _LIBCPP_TYPE_VIS function; // undefined +template<class _Fp> class _LIBCPP_TYPE_VIS_ONLY function; // undefined namespace __function { @@ -1379,7 +1393,7 @@ __func<_Fp, _Alloc, _Rp(_ArgTypes...)>::target_type() const _NOEXCEPT } // __function template<class _Rp, class ..._ArgTypes> -class _LIBCPP_TYPE_VIS function<_Rp(_ArgTypes...)> +class _LIBCPP_TYPE_VIS_ONLY function<_Rp(_ArgTypes...)> : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>, public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)> { @@ -1801,11 +1815,11 @@ swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCE {return __x.swap(__y);} template<class _Tp> struct __is_bind_expression : public false_type {}; -template<class _Tp> struct _LIBCPP_TYPE_VIS is_bind_expression +template<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_bind_expression : public __is_bind_expression<typename remove_cv<_Tp>::type> {}; template<class _Tp> struct __is_placeholder : public integral_constant<int, 0> {}; -template<class _Tp> struct _LIBCPP_TYPE_VIS is_placeholder +template<class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_placeholder : public __is_placeholder<typename remove_cv<_Tp>::type> {}; namespace placeholders @@ -1813,16 +1827,16 @@ namespace placeholders template <int _Np> struct __ph {}; -extern __ph<1> _1; -extern __ph<2> _2; -extern __ph<3> _3; -extern __ph<4> _4; -extern __ph<5> _5; -extern __ph<6> _6; -extern __ph<7> _7; -extern __ph<8> _8; -extern __ph<9> _9; -extern __ph<10> _10; +_LIBCPP_FUNC_VIS extern __ph<1> _1; +_LIBCPP_FUNC_VIS extern __ph<2> _2; +_LIBCPP_FUNC_VIS extern __ph<3> _3; +_LIBCPP_FUNC_VIS extern __ph<4> _4; +_LIBCPP_FUNC_VIS extern __ph<5> _5; +_LIBCPP_FUNC_VIS extern __ph<6> _6; +_LIBCPP_FUNC_VIS extern __ph<7> _7; +_LIBCPP_FUNC_VIS extern __ph<8> _8; +_LIBCPP_FUNC_VIS extern __ph<9> _9; +_LIBCPP_FUNC_VIS extern __ph<10> _10; } // placeholders @@ -2184,7 +2198,7 @@ bind(_Fp&& __f, _BoundArgs&&... __bound_args) #endif // _LIBCPP_HAS_NO_VARIADICS template <> -struct _LIBCPP_TYPE_VIS hash<bool> +struct _LIBCPP_TYPE_VIS_ONLY hash<bool> : public unary_function<bool, size_t> { _LIBCPP_INLINE_VISIBILITY @@ -2192,7 +2206,7 @@ struct _LIBCPP_TYPE_VIS hash<bool> }; template <> -struct _LIBCPP_TYPE_VIS hash<char> +struct _LIBCPP_TYPE_VIS_ONLY hash<char> : public unary_function<char, size_t> { _LIBCPP_INLINE_VISIBILITY @@ -2200,7 +2214,7 @@ struct _LIBCPP_TYPE_VIS hash<char> }; template <> -struct _LIBCPP_TYPE_VIS hash<signed char> +struct _LIBCPP_TYPE_VIS_ONLY hash<signed char> : public unary_function<signed char, size_t> { _LIBCPP_INLINE_VISIBILITY @@ -2208,7 +2222,7 @@ struct _LIBCPP_TYPE_VIS hash<signed char> }; template <> -struct _LIBCPP_TYPE_VIS hash<unsigned char> +struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned char> : public unary_function<unsigned char, size_t> { _LIBCPP_INLINE_VISIBILITY @@ -2218,7 +2232,7 @@ struct _LIBCPP_TYPE_VIS hash<unsigned char> #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS template <> -struct _LIBCPP_TYPE_VIS hash<char16_t> +struct _LIBCPP_TYPE_VIS_ONLY hash<char16_t> : public unary_function<char16_t, size_t> { _LIBCPP_INLINE_VISIBILITY @@ -2226,7 +2240,7 @@ struct _LIBCPP_TYPE_VIS hash<char16_t> }; template <> -struct _LIBCPP_TYPE_VIS hash<char32_t> +struct _LIBCPP_TYPE_VIS_ONLY hash<char32_t> : public unary_function<char32_t, size_t> { _LIBCPP_INLINE_VISIBILITY @@ -2236,7 +2250,7 @@ struct _LIBCPP_TYPE_VIS hash<char32_t> #endif // _LIBCPP_HAS_NO_UNICODE_CHARS template <> -struct _LIBCPP_TYPE_VIS hash<wchar_t> +struct _LIBCPP_TYPE_VIS_ONLY hash<wchar_t> : public unary_function<wchar_t, size_t> { _LIBCPP_INLINE_VISIBILITY @@ -2244,7 +2258,7 @@ struct _LIBCPP_TYPE_VIS hash<wchar_t> }; template <> -struct _LIBCPP_TYPE_VIS hash<short> +struct _LIBCPP_TYPE_VIS_ONLY hash<short> : public unary_function<short, size_t> { _LIBCPP_INLINE_VISIBILITY @@ -2252,7 +2266,7 @@ struct _LIBCPP_TYPE_VIS hash<short> }; template <> -struct _LIBCPP_TYPE_VIS hash<unsigned short> +struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned short> : public unary_function<unsigned short, size_t> { _LIBCPP_INLINE_VISIBILITY @@ -2260,7 +2274,7 @@ struct _LIBCPP_TYPE_VIS hash<unsigned short> }; template <> -struct _LIBCPP_TYPE_VIS hash<int> +struct _LIBCPP_TYPE_VIS_ONLY hash<int> : public unary_function<int, size_t> { _LIBCPP_INLINE_VISIBILITY @@ -2268,7 +2282,7 @@ struct _LIBCPP_TYPE_VIS hash<int> }; template <> -struct _LIBCPP_TYPE_VIS hash<unsigned int> +struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned int> : public unary_function<unsigned int, size_t> { _LIBCPP_INLINE_VISIBILITY @@ -2276,7 +2290,7 @@ struct _LIBCPP_TYPE_VIS hash<unsigned int> }; template <> -struct _LIBCPP_TYPE_VIS hash<long> +struct _LIBCPP_TYPE_VIS_ONLY hash<long> : public unary_function<long, size_t> { _LIBCPP_INLINE_VISIBILITY @@ -2284,7 +2298,7 @@ struct _LIBCPP_TYPE_VIS hash<long> }; template <> -struct _LIBCPP_TYPE_VIS hash<unsigned long> +struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long> : public unary_function<unsigned long, size_t> { _LIBCPP_INLINE_VISIBILITY @@ -2292,19 +2306,19 @@ struct _LIBCPP_TYPE_VIS hash<unsigned long> }; template <> -struct _LIBCPP_TYPE_VIS hash<long long> +struct _LIBCPP_TYPE_VIS_ONLY hash<long long> : public __scalar_hash<long long> { }; template <> -struct _LIBCPP_TYPE_VIS hash<unsigned long long> +struct _LIBCPP_TYPE_VIS_ONLY hash<unsigned long long> : public __scalar_hash<unsigned long long> { }; template <> -struct _LIBCPP_TYPE_VIS hash<float> +struct _LIBCPP_TYPE_VIS_ONLY hash<float> : public __scalar_hash<float> { _LIBCPP_INLINE_VISIBILITY @@ -2318,7 +2332,7 @@ struct _LIBCPP_TYPE_VIS hash<float> }; template <> -struct _LIBCPP_TYPE_VIS hash<double> +struct _LIBCPP_TYPE_VIS_ONLY hash<double> : public __scalar_hash<double> { _LIBCPP_INLINE_VISIBILITY @@ -2332,7 +2346,7 @@ struct _LIBCPP_TYPE_VIS hash<double> }; template <> -struct _LIBCPP_TYPE_VIS hash<long double> +struct _LIBCPP_TYPE_VIS_ONLY hash<long double> : public __scalar_hash<long double> { _LIBCPP_INLINE_VISIBILITY @@ -2381,6 +2395,22 @@ struct _LIBCPP_TYPE_VIS hash<long double> } }; +#if _LIBCPP_STD_VER > 11 +template <class _Tp> +struct _LIBCPP_TYPE_VIS_ONLY hash + : public unary_function<_Tp, size_t> +{ + static_assert(is_enum<_Tp>::value, "This hash only works for enumeration types"); + + _LIBCPP_INLINE_VISIBILITY + size_t operator()(_Tp __v) const _NOEXCEPT + { + typedef typename underlying_type<_Tp>::type type; + return hash<type>{}(static_cast<type>(__v)); + } +}; +#endif + // struct hash<T*> in <memory> _LIBCPP_END_NAMESPACE_STD diff --git a/system/include/libcxx/future b/system/include/libcxx/future index dae1a4b8..73d5456d 100644 --- a/system/include/libcxx/future +++ b/system/include/libcxx/future @@ -19,10 +19,10 @@ namespace std enum class future_errc { - broken_promise, - future_already_retrieved, + future_already_retrieved = 1, promise_already_satisfied, - no_state + no_state, + broken_promise }; enum class launch @@ -309,11 +309,11 @@ public: }; template <class F, class... Args> - future<typename result_of<F(Args...)>::type> + future<typename result_of<typename decay<F>::type(typename decay<Args>::type...)>::type> async(F&& f, Args&&... args); template <class F, class... Args> - future<typename result_of<F(Args...)>::type> + future<typename result_of<typename decay<F>::type(typename decay<Args>::type...)>::type> async(launch policy, F&& f, Args&&... args); template <class> class packaged_task; // undefined @@ -379,19 +379,19 @@ _LIBCPP_BEGIN_NAMESPACE_STD //enum class future_errc _LIBCPP_DECLARE_STRONG_ENUM(future_errc) { - broken_promise, - future_already_retrieved, + future_already_retrieved = 1, promise_already_satisfied, - no_state + no_state, + broken_promise }; _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(future_errc) template <> -struct _LIBCPP_TYPE_VIS is_error_code_enum<future_errc> : public true_type {}; +struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum<future_errc> : public true_type {}; #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS template <> -struct _LIBCPP_TYPE_VIS is_error_code_enum<future_errc::__lx> : public true_type { }; +struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum<future_errc::__lx> : public true_type { }; #endif //enum class launch @@ -508,7 +508,7 @@ public: virtual ~future_error() _NOEXCEPT; }; -class __assoc_sub_state +class _LIBCPP_TYPE_VIS __assoc_sub_state : public __shared_count { protected: @@ -542,14 +542,14 @@ public: __state_ |= __future_attached; } _LIBCPP_INLINE_VISIBILITY - bool __has_future_attached() const {return __state_ & __future_attached;} + bool __has_future_attached() const {return (__state_ & __future_attached) != 0;} _LIBCPP_INLINE_VISIBILITY void __set_deferred() {__state_ |= deferred;} void __make_ready(); _LIBCPP_INLINE_VISIBILITY - bool __is_ready() const {return __state_ & ready;} + bool __is_ready() const {return (__state_ & ready) != 0;} void set_value(); void set_value_at_thread_exit(); @@ -727,7 +727,7 @@ __assoc_state<_Rp&>::set_value(_Rp& __arg) if (this->__has_value()) throw future_error(make_error_code(future_errc::promise_already_satisfied)); #endif - __value_ = &__arg; + __value_ = _VSTD::addressof(__arg); this->__state_ |= base::__constructed | base::ready; __lk.unlock(); __cv_.notify_all(); @@ -742,7 +742,7 @@ __assoc_state<_Rp&>::set_value_at_thread_exit(_Rp& __arg) if (this->__has_value()) throw future_error(make_error_code(future_errc::promise_already_satisfied)); #endif - __value_ = &__arg; + __value_ = _VSTD::addressof(__arg); this->__state_ |= base::__constructed; __thread_local_data()->__make_ready_at_thread_exit(this); __lk.unlock(); @@ -778,7 +778,7 @@ void __assoc_state_alloc<_Rp, _Alloc>::__on_zero_shared() _NOEXCEPT { if (this->__state_ & base::__constructed) - reinterpret_cast<_Rp*>(&this->__value_)->~_Rp(); + reinterpret_cast<_Rp*>(_VSTD::addressof(this->__value_))->~_Rp(); typename _Alloc::template rebind<__assoc_state_alloc>::other __a(__alloc_); this->~__assoc_state_alloc(); __a.deallocate(this, 1); @@ -1032,12 +1032,12 @@ __async_assoc_state<void, _Fp>::__on_zero_shared() _NOEXCEPT base::__on_zero_shared(); } -template <class _Rp> class _LIBCPP_TYPE_VIS promise; -template <class _Rp> class _LIBCPP_TYPE_VIS shared_future; +template <class _Rp> class _LIBCPP_TYPE_VIS_ONLY promise; +template <class _Rp> class _LIBCPP_TYPE_VIS_ONLY shared_future; // future -template <class _Rp> class _LIBCPP_TYPE_VIS future; +template <class _Rp> class _LIBCPP_TYPE_VIS_ONLY future; template <class _Rp, class _Fp> future<_Rp> @@ -1056,7 +1056,7 @@ __make_async_assoc_state(_Fp __f); #endif template <class _Rp> -class _LIBCPP_TYPE_VIS future +class _LIBCPP_TYPE_VIS_ONLY future { __assoc_state<_Rp>* __state_; @@ -1160,7 +1160,7 @@ future<_Rp>::get() } template <class _Rp> -class _LIBCPP_TYPE_VIS future<_Rp&> +class _LIBCPP_TYPE_VIS_ONLY future<_Rp&> { __assoc_state<_Rp&>* __state_; @@ -1341,7 +1341,7 @@ swap(future<_Rp>& __x, future<_Rp>& __y) _NOEXCEPT template <class _Callable> class packaged_task; template <class _Rp> -class _LIBCPP_TYPE_VIS promise +class _LIBCPP_TYPE_VIS_ONLY promise { __assoc_state<_Rp>* __state_; @@ -1519,7 +1519,7 @@ promise<_Rp>::set_exception_at_thread_exit(exception_ptr __p) // promise<R&> template <class _Rp> -class _LIBCPP_TYPE_VIS promise<_Rp&> +class _LIBCPP_TYPE_VIS_ONLY promise<_Rp&> { __assoc_state<_Rp&>* __state_; @@ -1736,7 +1736,7 @@ swap(promise<_Rp>& __x, promise<_Rp>& __y) _NOEXCEPT } template <class _Rp, class _Alloc> - struct _LIBCPP_TYPE_VIS uses_allocator<promise<_Rp>, _Alloc> + struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<promise<_Rp>, _Alloc> : public true_type {}; #ifndef _LIBCPP_HAS_NO_VARIADICS @@ -2000,7 +2000,7 @@ __packaged_task_function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) cons } template<class _Rp, class ..._ArgTypes> -class _LIBCPP_TYPE_VIS packaged_task<_Rp(_ArgTypes...)> +class _LIBCPP_TYPE_VIS_ONLY packaged_task<_Rp(_ArgTypes...)> { public: typedef _Rp result_type; @@ -2013,10 +2013,26 @@ public: // construction and destruction _LIBCPP_INLINE_VISIBILITY packaged_task() _NOEXCEPT : __p_(nullptr) {} - template <class _Fp> + template <class _Fp, + class = typename enable_if + < + !is_same< + typename decay<_Fp>::type, + packaged_task + >::value + >::type + > _LIBCPP_INLINE_VISIBILITY explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {} - template <class _Fp, class _Allocator> + template <class _Fp, class _Allocator, + class = typename enable_if + < + !is_same< + typename decay<_Fp>::type, + packaged_task + >::value + >::type + > _LIBCPP_INLINE_VISIBILITY explicit packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)), @@ -2115,7 +2131,7 @@ packaged_task<_Rp(_ArgTypes...)>::reset() } template<class ..._ArgTypes> -class _LIBCPP_TYPE_VIS packaged_task<void(_ArgTypes...)> +class _LIBCPP_TYPE_VIS_ONLY packaged_task<void(_ArgTypes...)> { public: typedef void result_type; @@ -2128,10 +2144,26 @@ public: // construction and destruction _LIBCPP_INLINE_VISIBILITY packaged_task() _NOEXCEPT : __p_(nullptr) {} - template <class _Fp> + template <class _Fp, + class = typename enable_if + < + !is_same< + typename decay<_Fp>::type, + packaged_task + >::value + >::type + > _LIBCPP_INLINE_VISIBILITY explicit packaged_task(_Fp&& __f) : __f_(_VSTD::forward<_Fp>(__f)) {} - template <class _Fp, class _Allocator> + template <class _Fp, class _Allocator, + class = typename enable_if + < + !is_same< + typename decay<_Fp>::type, + packaged_task + >::value + >::type + > _LIBCPP_INLINE_VISIBILITY explicit packaged_task(allocator_arg_t, const _Allocator& __a, _Fp&& __f) : __f_(allocator_arg, __a, _VSTD::forward<_Fp>(__f)), @@ -2240,7 +2272,7 @@ swap(packaged_task<_Callable>& __x, packaged_task<_Callable>& __y) _NOEXCEPT } template <class _Callable, class _Alloc> -struct _LIBCPP_TYPE_VIS uses_allocator<packaged_task<_Callable>, _Alloc> +struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<packaged_task<_Callable>, _Alloc> : public true_type {}; template <class _Rp, class _Fp> @@ -2299,20 +2331,32 @@ private: } }; +inline _LIBCPP_INLINE_VISIBILITY bool __does_policy_contain(launch __policy, launch __value ) +{ return (int(__policy) & int(__value)) != 0; } + template <class _Fp, class... _Args> future<typename __invoke_of<typename decay<_Fp>::type, typename decay<_Args>::type...>::type> async(launch __policy, _Fp&& __f, _Args&&... __args) { typedef __async_func<typename decay<_Fp>::type, typename decay<_Args>::type...> _BF; typedef typename _BF::_Rp _Rp; - future<_Rp> __r; - if (int(__policy) & int(launch::async)) - __r = _VSTD::__make_async_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)), + +#ifndef _LIBCPP_NO_EXCEPTIONS + try + { +#endif + if (__does_policy_contain(__policy, launch::async)) + return _VSTD::__make_async_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)), __decay_copy(_VSTD::forward<_Args>(__args))...)); - else if (int(__policy) & int(launch::deferred)) - __r = _VSTD::__make_deferred_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)), +#ifndef _LIBCPP_NO_EXCEPTIONS + } + catch ( ... ) { if (__policy == launch::async) throw ; } +#endif + + if (__does_policy_contain(__policy, launch::deferred)) + return _VSTD::__make_deferred_assoc_state<_Rp>(_BF(__decay_copy(_VSTD::forward<_Fp>(__f)), __decay_copy(_VSTD::forward<_Args>(__args))...)); - return __r; + return future<_Rp>{}; } template <class _Fp, class... _Args> @@ -2329,7 +2373,7 @@ async(_Fp&& __f, _Args&&... __args) // shared_future template <class _Rp> -class _LIBCPP_TYPE_VIS shared_future +class _LIBCPP_TYPE_VIS_ONLY shared_future { __assoc_state<_Rp>* __state_; @@ -2403,7 +2447,7 @@ shared_future<_Rp>::operator=(const shared_future& __rhs) } template <class _Rp> -class _LIBCPP_TYPE_VIS shared_future<_Rp&> +class _LIBCPP_TYPE_VIS_ONLY shared_future<_Rp&> { __assoc_state<_Rp&>* __state_; diff --git a/system/include/libcxx/initializer_list b/system/include/libcxx/initializer_list index 181313d1..663e49b6 100644 --- a/system/include/libcxx/initializer_list +++ b/system/include/libcxx/initializer_list @@ -29,15 +29,15 @@ public: typedef const E* iterator; typedef const E* const_iterator; - initializer_list() noexcept; + initializer_list() noexcept; // constexpr in C++14 - size_t size() const noexcept; - const E* begin() const noexcept; - const E* end() const noexcept; + size_t size() const noexcept; // constexpr in C++14 + const E* begin() const noexcept; // constexpr in C++14 + const E* end() const noexcept; // constexpr in C++14 }; -template<class E> const E* begin(initializer_list<E> il) noexcept; -template<class E> const E* end(initializer_list<E> il) noexcept; +template<class E> const E* begin(initializer_list<E> il) noexcept; // constexpr in C++14 +template<class E> const E* end(initializer_list<E> il) noexcept; // constexpr in C++14 } // std @@ -56,12 +56,13 @@ namespace std // purposefully not versioned #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template<class _Ep> -class _LIBCPP_TYPE_VIS initializer_list +class _LIBCPP_TYPE_VIS_ONLY initializer_list { const _Ep* __begin_; size_t __size_; _LIBCPP_ALWAYS_INLINE + _LIBCPP_CONSTEXPR_AFTER_CXX11 initializer_list(const _Ep* __b, size_t __s) _NOEXCEPT : __begin_(__b), __size_(__s) @@ -75,15 +76,26 @@ public: typedef const _Ep* iterator; typedef const _Ep* const_iterator; - _LIBCPP_ALWAYS_INLINE initializer_list() _NOEXCEPT : __begin_(nullptr), __size_(0) {} + _LIBCPP_ALWAYS_INLINE + _LIBCPP_CONSTEXPR_AFTER_CXX11 + initializer_list() _NOEXCEPT : __begin_(nullptr), __size_(0) {} - _LIBCPP_ALWAYS_INLINE size_t size() const _NOEXCEPT {return __size_;} - _LIBCPP_ALWAYS_INLINE const _Ep* begin() const _NOEXCEPT {return __begin_;} - _LIBCPP_ALWAYS_INLINE const _Ep* end() const _NOEXCEPT {return __begin_ + __size_;} + _LIBCPP_ALWAYS_INLINE + _LIBCPP_CONSTEXPR_AFTER_CXX11 + size_t size() const _NOEXCEPT {return __size_;} + + _LIBCPP_ALWAYS_INLINE + _LIBCPP_CONSTEXPR_AFTER_CXX11 + const _Ep* begin() const _NOEXCEPT {return __begin_;} + + _LIBCPP_ALWAYS_INLINE + _LIBCPP_CONSTEXPR_AFTER_CXX11 + const _Ep* end() const _NOEXCEPT {return __begin_ + __size_;} }; template<class _Ep> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX11 const _Ep* begin(initializer_list<_Ep> __il) _NOEXCEPT { @@ -92,6 +104,7 @@ begin(initializer_list<_Ep> __il) _NOEXCEPT template<class _Ep> inline _LIBCPP_INLINE_VISIBILITY +_LIBCPP_CONSTEXPR_AFTER_CXX11 const _Ep* end(initializer_list<_Ep> __il) _NOEXCEPT { diff --git a/system/include/libcxx/iomanip b/system/include/libcxx/iomanip index 0c58e198..cdb0d5f0 100644 --- a/system/include/libcxx/iomanip +++ b/system/include/libcxx/iomanip @@ -26,6 +26,17 @@ template <class charT, class moneyT> T8 put_money(const moneyT& mon, bool intl = template <class charT> T9 get_time(struct tm* tmb, const charT* fmt); template <class charT> T10 put_time(const struct tm* tmb, const charT* fmt); +template <class charT> + T11 quoted(const charT* s, charT delim=charT('"'), charT escape=charT('\\')); // C++14 + +template <class charT, class traits, class Allocator> + T12 quoted(const basic_string<charT, traits, Allocator>& s, + charT delim=charT('"'), charT escape=charT('\\')); // C++14 + +template <class charT, class traits, class Allocator> + T13 quoted(basic_string<charT, traits, Allocator>& s, + charT delim=charT('"'), charT escape=charT('\\')); // C++14 + } // std */ @@ -499,6 +510,142 @@ put_time(const tm* __tm, const _CharT* __fmt) return __iom_t10<_CharT>(__tm, __fmt); } +#if _LIBCPP_STD_VER > 11 + +template <class _CharT, class _Traits, class _ForwardIterator> +std::basic_ostream<_CharT, _Traits> & +__quoted_output ( basic_ostream<_CharT, _Traits> &__os, + _ForwardIterator __first, _ForwardIterator __last, _CharT __delim, _CharT __escape ) +{ + __os << __delim; + for ( ; __first != __last; ++ __first ) + { + if (_Traits::eq (*__first, __escape) || _Traits::eq (*__first, __delim)) + __os << __escape; + __os << *__first; + } + __os << __delim; + return __os; +} + +template <class _CharT, class _Traits, class _String> +basic_istream<_CharT, _Traits> & +__quoted_input ( basic_istream<_CharT, _Traits> &__is, _String & __string, _CharT __delim, _CharT __escape ) +{ + __string.clear (); + _CharT __c; + __is >> __c; + if ( __is.fail ()) + return __is; + + if (!_Traits::eq (__c, __delim)) // no delimiter, read the whole string + { + __is.unget (); + __is >> __string; + return __is; + } + + __save_flags<_CharT, _Traits> sf(__is); + noskipws (__is); + while (true) + { + __is >> __c; + if ( __is.fail ()) + break; + if (_Traits::eq (__c, __escape)) + { + __is >> __c; + if ( __is.fail ()) + break; + } + else if (_Traits::eq (__c, __delim)) + break; + __string.push_back ( __c ); + } + return __is; +} + + +template <class _CharT, class _Iter, class _Traits=char_traits<_CharT>> +struct __quoted_output_proxy +{ + _Iter __first; + _Iter __last; + _CharT __delim; + _CharT __escape; + + __quoted_output_proxy(_Iter __f, _Iter __l, _CharT __d, _CharT __e) + : __first(__f), __last(__l), __delim(__d), __escape(__e) {} + // This would be a nice place for a string_ref +}; + +template <class _CharT, class _Traits, class _Iter> +basic_ostream<_CharT, _Traits>& operator<<( + basic_ostream<_CharT, _Traits>& __os, + const __quoted_output_proxy<_CharT, _Iter, _Traits> & __proxy) +{ + return __quoted_output (__os, __proxy.__first, __proxy.__last, __proxy.__delim, __proxy.__escape); +} + +template <class _CharT, class _Traits, class _Allocator> +struct __quoted_proxy +{ + basic_string<_CharT, _Traits, _Allocator> &__string; + _CharT __delim; + _CharT __escape; + + __quoted_proxy(basic_string<_CharT, _Traits, _Allocator> &__s, _CharT __d, _CharT __e) + : __string(__s), __delim(__d), __escape(__e) {} +}; + +template <class _CharT, class _Traits, class _Allocator> +_LIBCPP_INLINE_VISIBILITY +basic_ostream<_CharT, _Traits>& operator<<( + basic_ostream<_CharT, _Traits>& __os, + const __quoted_proxy<_CharT, _Traits, _Allocator> & __proxy) +{ + return __quoted_output (__os, __proxy.string.cbegin (), __proxy.string.cend (), __proxy.__delim, __proxy.__escape); +} + +// extractor for non-const basic_string& proxies +template <class _CharT, class _Traits, class _Allocator> +_LIBCPP_INLINE_VISIBILITY +basic_istream<_CharT, _Traits>& operator>>( + basic_istream<_CharT, _Traits>& __is, + const __quoted_proxy<_CharT, _Traits, _Allocator> & __proxy) +{ + return __quoted_input ( __is, __proxy.__string, __proxy.__delim, __proxy.__escape ); +} + + +template <class _CharT> +_LIBCPP_INLINE_VISIBILITY +__quoted_output_proxy<_CharT, const _CharT *> +quoted ( const _CharT *__s, _CharT __delim = _CharT('"'), _CharT __escape =_CharT('\\')) +{ + const _CharT *__end = __s; + while ( *__end ) ++__end; + return __quoted_output_proxy<_CharT, const _CharT *> ( __s, __end, __delim, __escape ); +} + +template <class _CharT, class _Traits, class _Allocator> +_LIBCPP_INLINE_VISIBILITY +__quoted_output_proxy<_CharT, typename basic_string <_CharT, _Traits, _Allocator>::const_iterator> +quoted ( const basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\')) +{ + return __quoted_output_proxy<_CharT, + typename basic_string <_CharT, _Traits, _Allocator>::const_iterator> + ( __s.cbegin(), __s.cend (), __delim, __escape ); +} + +template <class _CharT, class _Traits, class _Allocator> +__quoted_proxy<_CharT, _Traits, _Allocator> +quoted ( basic_string <_CharT, _Traits, _Allocator> &__s, _CharT __delim = _CharT('"'), _CharT __escape=_CharT('\\')) +{ + return __quoted_proxy<_CharT, _Traits, _Allocator>( __s, __delim, __escape ); +} +#endif + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_IOMANIP diff --git a/system/include/libcxx/ios b/system/include/libcxx/ios index c10003d0..b6cf0766 100644 --- a/system/include/libcxx/ios +++ b/system/include/libcxx/ios @@ -203,9 +203,9 @@ enum class io_errc }; concept_map ErrorCodeEnum<io_errc> { }; -error_code make_error_code(io_errc e); -error_condition make_error_condition(io_errc e); -storage-class-specifier const error_category& iostream_category; +error_code make_error_code(io_errc e) noexcept; +error_condition make_error_condition(io_errc e) noexcept; +storage-class-specifier const error_category& iostream_category() noexcept; } // std @@ -216,6 +216,10 @@ storage-class-specifier const error_category& iostream_category; #include <__locale> #include <system_error> +#if __has_feature(cxx_atomic) +#include <atomic> // for __xindex_ +#endif + #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) #pragma GCC system_header #endif @@ -319,7 +323,7 @@ public: _LIBCPP_INLINE_VISIBILITY bool bad() const; _LIBCPP_INLINE_VISIBILITY iostate exceptions() const; - _LIBCPP_INLINE_VISIBILITY void exceptions(iostate __except); + _LIBCPP_INLINE_VISIBILITY void exceptions(iostate __iostate); void __set_badbit_and_consider_rethrow(); void __set_failbit_and_consider_rethrow(); @@ -363,7 +367,11 @@ private: int* __index_; size_t __event_size_; size_t __event_cap_; +#if __has_feature(cxx_atomic) && !defined(__EMSCRIPTEN__) + static atomic<int> __xindex_; +#else static int __xindex_; +#endif long* __iarray_; size_t __iarray_size_; size_t __iarray_cap_; @@ -380,26 +388,26 @@ _LIBCPP_DECLARE_STRONG_ENUM(io_errc) _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(io_errc) template <> -struct _LIBCPP_TYPE_VIS is_error_code_enum<io_errc> : public true_type { }; +struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum<io_errc> : public true_type { }; #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS template <> -struct _LIBCPP_TYPE_VIS is_error_code_enum<io_errc::__lx> : public true_type { }; +struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum<io_errc::__lx> : public true_type { }; #endif _LIBCPP_FUNC_VIS -const error_category& iostream_category(); +const error_category& iostream_category() _NOEXCEPT; inline _LIBCPP_INLINE_VISIBILITY error_code -make_error_code(io_errc __e) +make_error_code(io_errc __e) _NOEXCEPT { return error_code(static_cast<int>(__e), iostream_category()); } inline _LIBCPP_INLINE_VISIBILITY error_condition -make_error_condition(io_errc __e) +make_error_condition(io_errc __e) _NOEXCEPT { return error_condition(static_cast<int>(__e), iostream_category()); } @@ -527,21 +535,21 @@ inline _LIBCPP_INLINE_VISIBILITY bool ios_base::eof() const { - return __rdstate_ & eofbit; + return (__rdstate_ & eofbit) != 0; } inline _LIBCPP_INLINE_VISIBILITY bool ios_base::fail() const { - return __rdstate_ & (failbit | badbit); + return (__rdstate_ & (failbit | badbit)) != 0; } inline _LIBCPP_INLINE_VISIBILITY bool ios_base::bad() const { - return __rdstate_ & badbit; + return (__rdstate_ & badbit) != 0; } inline _LIBCPP_INLINE_VISIBILITY @@ -553,14 +561,14 @@ ios_base::exceptions() const inline _LIBCPP_INLINE_VISIBILITY void -ios_base::exceptions(iostate __except) +ios_base::exceptions(iostate __iostate) { - __exceptions_ = __except; + __exceptions_ = __iostate; clear(__rdstate_); } template <class _CharT, class _Traits> -class _LIBCPP_TYPE_VIS basic_ios +class _LIBCPP_TYPE_VIS_ONLY basic_ios : public ios_base { public: @@ -585,7 +593,7 @@ public: _LIBCPP_ALWAYS_INLINE bool bad() const {return ios_base::bad();} _LIBCPP_ALWAYS_INLINE iostate exceptions() const {return ios_base::exceptions();} - _LIBCPP_ALWAYS_INLINE void exceptions(iostate __except) {ios_base::exceptions(__except);} + _LIBCPP_ALWAYS_INLINE void exceptions(iostate __iostate) {ios_base::exceptions(__iostate);} // 27.5.4.1 Constructor/destructor: _LIBCPP_INLINE_VISIBILITY diff --git a/system/include/libcxx/iosfwd b/system/include/libcxx/iosfwd index 849d7e51..d24c227b 100644 --- a/system/include/libcxx/iosfwd +++ b/system/include/libcxx/iosfwd @@ -97,47 +97,47 @@ _LIBCPP_BEGIN_NAMESPACE_STD class _LIBCPP_TYPE_VIS ios_base; -template<class _CharT> struct _LIBCPP_TYPE_VIS char_traits; -template<class _Tp> class _LIBCPP_TYPE_VIS allocator; +template<class _CharT> struct _LIBCPP_TYPE_VIS_ONLY char_traits; +template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY allocator; template <class _CharT, class _Traits = char_traits<_CharT> > - class _LIBCPP_TYPE_VIS basic_ios; + class _LIBCPP_TYPE_VIS_ONLY basic_ios; template <class _CharT, class _Traits = char_traits<_CharT> > - class _LIBCPP_TYPE_VIS basic_streambuf; + class _LIBCPP_TYPE_VIS_ONLY basic_streambuf; template <class _CharT, class _Traits = char_traits<_CharT> > - class _LIBCPP_TYPE_VIS basic_istream; + class _LIBCPP_TYPE_VIS_ONLY basic_istream; template <class _CharT, class _Traits = char_traits<_CharT> > - class _LIBCPP_TYPE_VIS basic_ostream; + class _LIBCPP_TYPE_VIS_ONLY basic_ostream; template <class _CharT, class _Traits = char_traits<_CharT> > - class _LIBCPP_TYPE_VIS basic_iostream; + class _LIBCPP_TYPE_VIS_ONLY basic_iostream; template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> > - class _LIBCPP_TYPE_VIS basic_stringbuf; + class _LIBCPP_TYPE_VIS_ONLY basic_stringbuf; template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> > - class _LIBCPP_TYPE_VIS basic_istringstream; + class _LIBCPP_TYPE_VIS_ONLY basic_istringstream; template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> > - class _LIBCPP_TYPE_VIS basic_ostringstream; + class _LIBCPP_TYPE_VIS_ONLY basic_ostringstream; template <class _CharT, class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> > - class _LIBCPP_TYPE_VIS basic_stringstream; + class _LIBCPP_TYPE_VIS_ONLY basic_stringstream; template <class _CharT, class _Traits = char_traits<_CharT> > - class _LIBCPP_TYPE_VIS basic_filebuf; + class _LIBCPP_TYPE_VIS_ONLY basic_filebuf; template <class _CharT, class _Traits = char_traits<_CharT> > - class _LIBCPP_TYPE_VIS basic_ifstream; + class _LIBCPP_TYPE_VIS_ONLY basic_ifstream; template <class _CharT, class _Traits = char_traits<_CharT> > - class _LIBCPP_TYPE_VIS basic_ofstream; + class _LIBCPP_TYPE_VIS_ONLY basic_ofstream; template <class _CharT, class _Traits = char_traits<_CharT> > - class _LIBCPP_TYPE_VIS basic_fstream; + class _LIBCPP_TYPE_VIS_ONLY basic_fstream; template <class _CharT, class _Traits = char_traits<_CharT> > - class _LIBCPP_TYPE_VIS istreambuf_iterator; + class _LIBCPP_TYPE_VIS_ONLY istreambuf_iterator; template <class _CharT, class _Traits = char_traits<_CharT> > - class _LIBCPP_TYPE_VIS ostreambuf_iterator; + class _LIBCPP_TYPE_VIS_ONLY ostreambuf_iterator; typedef basic_ios<char> ios; typedef basic_ios<wchar_t> wios; @@ -172,7 +172,7 @@ typedef basic_ifstream<wchar_t> wifstream; typedef basic_ofstream<wchar_t> wofstream; typedef basic_fstream<wchar_t> wfstream; -template <class _State> class _LIBCPP_TYPE_VIS fpos; +template <class _State> class _LIBCPP_TYPE_VIS_ONLY fpos; typedef fpos<mbstate_t> streampos; typedef fpos<mbstate_t> wstreampos; #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS @@ -185,7 +185,7 @@ typedef long long streamoff; // for char_traits in <string> template <class _CharT, // for <stdexcept> class _Traits = char_traits<_CharT>, class _Allocator = allocator<_CharT> > - class _LIBCPP_TYPE_VIS basic_string; + class _LIBCPP_TYPE_VIS_ONLY basic_string; typedef basic_string<char, char_traits<char>, allocator<char> > string; typedef basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> > wstring; diff --git a/system/include/libcxx/istream b/system/include/libcxx/istream index f3e74c38..14fa4660 100644 --- a/system/include/libcxx/istream +++ b/system/include/libcxx/istream @@ -164,7 +164,7 @@ template <class charT, class traits, class T> _LIBCPP_BEGIN_NAMESPACE_STD template <class _CharT, class _Traits> -class _LIBCPP_TYPE_VIS basic_istream +class _LIBCPP_TYPE_VIS_ONLY basic_istream : virtual public basic_ios<_CharT, _Traits> { streamsize __gc_; @@ -194,7 +194,7 @@ protected: public: // 27.7.1.1.3 Prefix/suffix: - class _LIBCPP_TYPE_VIS sentry; + class _LIBCPP_TYPE_VIS_ONLY sentry; // 27.7.1.2 Formatted input: basic_istream& operator>>(basic_istream& (*__pf)(basic_istream&)); @@ -244,7 +244,7 @@ public: }; template <class _CharT, class _Traits> -class _LIBCPP_TYPE_VIS basic_istream<_CharT, _Traits>::sentry +class _LIBCPP_TYPE_VIS_ONLY basic_istream<_CharT, _Traits>::sentry { bool __ok_; @@ -1369,8 +1369,10 @@ basic_istream<_CharT, _Traits>::seekg(pos_type __pos) this->clear(this->rdstate() & ~ios_base::eofbit); sentry __sen(*this, true); if (__sen) + { if (this->rdbuf()->pubseekpos(__pos, ios_base::in) == pos_type(-1)) this->setstate(ios_base::failbit); + } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) @@ -1391,7 +1393,10 @@ basic_istream<_CharT, _Traits>::seekg(off_type __off, ios_base::seekdir __dir) #endif // _LIBCPP_NO_EXCEPTIONS sentry __sen(*this, true); if (__sen) - this->rdbuf()->pubseekoff(__off, __dir, ios_base::in); + { + if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::in) == pos_type(-1)) + this->setstate(ios_base::failbit); + } #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) @@ -1451,7 +1456,7 @@ operator>>(basic_istream<_CharT, _Traits>&& __is, _Tp& __x) #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class _CharT, class _Traits> -class _LIBCPP_TYPE_VIS basic_iostream +class _LIBCPP_TYPE_VIS_ONLY basic_iostream : public basic_istream<_CharT, _Traits>, public basic_ostream<_CharT, _Traits> { @@ -1702,9 +1707,9 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bitset<_Size>& __x) return __is; } -_LIBCPP_EXTERN_TEMPLATE(class basic_istream<char>) -_LIBCPP_EXTERN_TEMPLATE(class basic_istream<wchar_t>) -_LIBCPP_EXTERN_TEMPLATE(class basic_iostream<char>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_istream<char>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_istream<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_iostream<char>) _LIBCPP_END_NAMESPACE_STD diff --git a/system/include/libcxx/iterator b/system/include/libcxx/iterator index 858510d1..d16aa2aa 100644 --- a/system/include/libcxx/iterator +++ b/system/include/libcxx/iterator @@ -309,6 +309,19 @@ template <class C> auto end(const C& c) -> decltype(c.end()); template <class T, size_t N> T* begin(T (&array)[N]); template <class T, size_t N> T* end(T (&array)[N]); +template <class C> auto cbegin(const C& c) -> decltype(std::begin(c)); // C++14 +template <class C> auto cend(const C& c) -> decltype(std::end(c)); // C++14 +template <class C> auto rbegin(C& c) -> decltype(c.rbegin()); // C++14 +template <class C> auto rbegin(const C& c) -> decltype(c.rbegin()); // C++14 +template <class C> auto rend(C& c) -> decltype(c.rend()); // C++14 +template <class C> auto rend(const C& c) -> decltype(c.rend()); // C++14 +template <class E> reverse_iterator<const E*> rbegin(initializer_list<E> il); // C++14 +template <class E> reverse_iterator<const E*> rend(initializer_list<E> il); // C++14 +template <class T, size_t N> reverse_iterator<T*> rbegin(T (&array)[N]); // C++14 +template <class T, size_t N> reverse_iterator<T*> rend(T (&array)[N]); // C++14 +template <class C> auto crbegin(const C& c) -> decltype(std::rbegin(c)); // C++14 +template <class C> auto crend(const C& c) -> decltype(std::rend(c)); // C++14 + } // std */ @@ -317,11 +330,12 @@ template <class T, size_t N> T* end(T (&array)[N]); #include <type_traits> #include <cstddef> #include <iosfwd> +#include <initializer_list> #ifdef __APPLE__ #include <Availability.h> #endif -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG # include <__debug> #else # define _LIBCPP_ASSERT(x, m) ((void)0) @@ -333,11 +347,11 @@ template <class T, size_t N> T* end(T (&array)[N]); _LIBCPP_BEGIN_NAMESPACE_STD -struct _LIBCPP_TYPE_VIS input_iterator_tag {}; -struct _LIBCPP_TYPE_VIS output_iterator_tag {}; -struct _LIBCPP_TYPE_VIS forward_iterator_tag : public input_iterator_tag {}; -struct _LIBCPP_TYPE_VIS bidirectional_iterator_tag : public forward_iterator_tag {}; -struct _LIBCPP_TYPE_VIS random_access_iterator_tag : public bidirectional_iterator_tag {}; +struct _LIBCPP_TYPE_VIS_ONLY input_iterator_tag {}; +struct _LIBCPP_TYPE_VIS_ONLY output_iterator_tag {}; +struct _LIBCPP_TYPE_VIS_ONLY forward_iterator_tag : public input_iterator_tag {}; +struct _LIBCPP_TYPE_VIS_ONLY bidirectional_iterator_tag : public forward_iterator_tag {}; +struct _LIBCPP_TYPE_VIS_ONLY random_access_iterator_tag : public bidirectional_iterator_tag {}; template <class _Tp> struct __has_iterator_category @@ -380,11 +394,11 @@ struct __iterator_traits<_Iter, true> // the client expects instead of failing at compile time. template <class _Iter> -struct _LIBCPP_TYPE_VIS iterator_traits +struct _LIBCPP_TYPE_VIS_ONLY iterator_traits : __iterator_traits<_Iter, __has_iterator_category<_Iter>::value> {}; template<class _Tp> -struct _LIBCPP_TYPE_VIS iterator_traits<_Tp*> +struct _LIBCPP_TYPE_VIS_ONLY iterator_traits<_Tp*> { typedef ptrdiff_t difference_type; typedef typename remove_const<_Tp>::type value_type; @@ -415,7 +429,7 @@ struct __is_random_access_iterator : public __has_iterator_category_convertible_ template<class _Category, class _Tp, class _Distance = ptrdiff_t, class _Pointer = _Tp*, class _Reference = _Tp&> -struct _LIBCPP_TYPE_VIS iterator +struct _LIBCPP_TYPE_VIS_ONLY iterator { typedef _Tp value_type; typedef _Distance difference_type; @@ -512,7 +526,7 @@ prev(_BidiretionalIter __x, } template <class _Iter> -class _LIBCPP_TYPE_VIS reverse_iterator +class _LIBCPP_TYPE_VIS_ONLY reverse_iterator : public iterator<typename iterator_traits<_Iter>::iterator_category, typename iterator_traits<_Iter>::value_type, typename iterator_traits<_Iter>::difference_type, @@ -619,7 +633,7 @@ operator+(typename reverse_iterator<_Iter>::difference_type __n, const reverse_i } template <class _Container> -class _LIBCPP_TYPE_VIS back_insert_iterator +class _LIBCPP_TYPE_VIS_ONLY back_insert_iterator : public iterator<output_iterator_tag, void, void, @@ -652,7 +666,7 @@ back_inserter(_Container& __x) } template <class _Container> -class _LIBCPP_TYPE_VIS front_insert_iterator +class _LIBCPP_TYPE_VIS_ONLY front_insert_iterator : public iterator<output_iterator_tag, void, void, @@ -685,7 +699,7 @@ front_inserter(_Container& __x) } template <class _Container> -class _LIBCPP_TYPE_VIS insert_iterator +class _LIBCPP_TYPE_VIS_ONLY insert_iterator : public iterator<output_iterator_tag, void, void, @@ -721,7 +735,7 @@ inserter(_Container& __x, typename _Container::iterator __i) template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT>, class _Distance = ptrdiff_t> -class _LIBCPP_TYPE_VIS istream_iterator +class _LIBCPP_TYPE_VIS_ONLY istream_iterator : public iterator<input_iterator_tag, _Tp, _Distance, const _Tp*, const _Tp&> { public: @@ -760,7 +774,7 @@ public: }; template <class _Tp, class _CharT = char, class _Traits = char_traits<_CharT> > -class _LIBCPP_TYPE_VIS ostream_iterator +class _LIBCPP_TYPE_VIS_ONLY ostream_iterator : public iterator<output_iterator_tag, void, void, void, void> { public: @@ -789,7 +803,7 @@ public: }; template<class _CharT, class _Traits> -class _LIBCPP_TYPE_VIS istreambuf_iterator +class _LIBCPP_TYPE_VIS_ONLY istreambuf_iterator : public iterator<input_iterator_tag, _CharT, typename _Traits::off_type, _CharT*, _CharT> @@ -860,7 +874,7 @@ bool operator!=(const istreambuf_iterator<_CharT,_Traits>& __a, {return !__a.equal(__b);} template <class _CharT, class _Traits> -class _LIBCPP_TYPE_VIS ostreambuf_iterator +class _LIBCPP_TYPE_VIS_ONLY ostreambuf_iterator : public iterator<output_iterator_tag, void, void, void, void> { public: @@ -901,7 +915,7 @@ public: }; template <class _Iter> -class _LIBCPP_TYPE_VIS move_iterator +class _LIBCPP_TYPE_VIS_ONLY move_iterator { private: _Iter __i; @@ -1016,7 +1030,7 @@ operator+(typename move_iterator<_Iter>::difference_type __n, const move_iterato template <class _Iter> inline _LIBCPP_INLINE_VISIBILITY move_iterator<_Iter> -make_move_iterator(const _Iter& __i) +make_move_iterator(_Iter __i) { return move_iterator<_Iter>(__i); } @@ -1197,12 +1211,13 @@ public: _LIBCPP_INLINE_VISIBILITY iterator_type base() const _NOEXCEPT {return __i;} private: - _LIBCPP_INLINE_VISIBILITY __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {} #if _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY __wrap_iter(const void* __p, iterator_type __x) : __i(__x) { __get_db()->__insert_ic(this, __p); } +#else + _LIBCPP_INLINE_VISIBILITY __wrap_iter(iterator_type __x) _NOEXCEPT : __i(__x) {} #endif template <class _Up> friend class __wrap_iter; @@ -1370,456 +1385,101 @@ operator+(typename __wrap_iter<_Iter>::difference_type __n, return __x; } -#ifdef _LIBCPP_DEBUG - -// __debug_iter - -template <class _Container, class _Iter> class __debug_iter; - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -bool -operator==(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -bool -operator<(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -bool -operator!=(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -bool -operator>(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -bool -operator>=(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -bool -operator<=(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter1, class _Iter2> -_LIBCPP_INLINE_VISIBILITY -typename __debug_iter<_Container, _Iter1>::difference_type -operator-(const __debug_iter<_Container, _Iter1>&, const __debug_iter<_Container, _Iter2>&); - -template <class _Container, class _Iter> -_LIBCPP_INLINE_VISIBILITY -__debug_iter<_Container, _Iter> -operator+(typename __debug_iter<_Container, _Iter>::difference_type, const __debug_iter<_Container, _Iter>&); - -template <class _Container, class _Iter> -class __debug_iter -{ -public: - typedef _Iter iterator_type; - typedef _Container __container_type; - typedef typename iterator_traits<iterator_type>::iterator_category iterator_category; - typedef typename iterator_traits<iterator_type>::value_type value_type; - typedef typename iterator_traits<iterator_type>::difference_type difference_type; - typedef typename iterator_traits<iterator_type>::pointer pointer; - typedef typename iterator_traits<iterator_type>::reference reference; -private: - iterator_type __i; - __debug_iter* __next; - __container_type* __cont; - -public: - _LIBCPP_INLINE_VISIBILITY __debug_iter() : __next(0), __cont(0) {} - _LIBCPP_INLINE_VISIBILITY __debug_iter(const __debug_iter& __x) - : __i(__x.base()), __next(0), __cont(0) {__set_owner(__x.__cont);} - __debug_iter& operator=(const __debug_iter& __x); - template <class _Up> _LIBCPP_INLINE_VISIBILITY __debug_iter(const __debug_iter<_Container, _Up>& __u, - typename enable_if<is_convertible<_Up, iterator_type>::value>::type* = 0) - : __i(__u.base()), __next(0), __cont(0) {__set_owner(__u.__cont);} - _LIBCPP_INLINE_VISIBILITY ~__debug_iter() {__remove_owner();} - _LIBCPP_INLINE_VISIBILITY reference operator*() const {assert(__is_deref()); return *__i;} - _LIBCPP_INLINE_VISIBILITY pointer operator->() const {return &(operator*());} - _LIBCPP_INLINE_VISIBILITY __debug_iter& operator++() {assert(__can_increment()); ++__i; return *this;} - _LIBCPP_INLINE_VISIBILITY __debug_iter operator++(int) - {__debug_iter __tmp(*this); operator++(); return __tmp;} - _LIBCPP_INLINE_VISIBILITY __debug_iter& operator--() {assert(__can_decrement()); --__i; return *this;} - _LIBCPP_INLINE_VISIBILITY __debug_iter operator--(int) - {__debug_iter __tmp(*this); operator--(); return __tmp;} - _LIBCPP_INLINE_VISIBILITY __debug_iter operator+ (difference_type __n) const - {__debug_iter __t(*this); __t += __n; return __t;} - __debug_iter& operator+=(difference_type __n); - _LIBCPP_INLINE_VISIBILITY __debug_iter operator- (difference_type __n) const - {__debug_iter __t(*this); __t -= __n; return __t;} - _LIBCPP_INLINE_VISIBILITY __debug_iter& operator-=(difference_type __n) - {*this += -__n; return *this;} - _LIBCPP_INLINE_VISIBILITY reference operator[](difference_type __n) const - {return *(*this + __n);} - -private: - _LIBCPP_INLINE_VISIBILITY __debug_iter(const __container_type* __c, iterator_type __x) - : __i(__x), __next(0), __cont(0) {__set_owner(__c);} - _LIBCPP_INLINE_VISIBILITY iterator_type base() const {return __i;} - - void __set_owner(const __container_type* __c); - void __remove_owner(); - static void __remove_all(__container_type* __c); - static void swap(__container_type* __x, __container_type* __y); - - _LIBCPP_INLINE_VISIBILITY bool __is_deref() const - {return __is_deref(__is_random_access_iterator<iterator_type>());} - bool __is_deref(false_type) const; - bool __is_deref(true_type) const; - _LIBCPP_INLINE_VISIBILITY bool __can_decrement() const - {return __can_decrement(integral_constant<int, is_pointer<iterator_type>::value ? 2: - __is_random_access_iterator<iterator_type>::value ? 1 : 0>());} - bool __can_decrement(integral_constant<int, 0>) const; - bool __can_decrement(integral_constant<int, 1>) const; - bool __can_decrement(integral_constant<int, 2>) const; - _LIBCPP_INLINE_VISIBILITY bool __can_increment() const - {return __can_increment(integral_constant<int, is_pointer<iterator_type>::value ? 2: - __is_random_access_iterator<iterator_type>::value ? 1 : 0>());} - bool __can_increment(integral_constant<int, 0>) const; - bool __can_increment(integral_constant<int, 1>) const; - bool __can_increment(integral_constant<int, 2>) const; - - _LIBCPP_INLINE_VISIBILITY bool __can_add(difference_type __n) const - {return __can_add(__n, is_pointer<iterator_type>());} - bool __can_add(difference_type __n, false_type) const; - bool __can_add(difference_type __n, true_type) const; - - template <class _Cp, class _Up> friend class __debug_iter; - friend class _Container::__self; - - template <class _Cp, class _Iter1, class _Iter2> - friend - bool - operator==(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1, class _Iter2> - friend - bool - operator<(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1, class _Iter2> - friend - bool - operator!=(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1, class _Iter2> - friend - bool - operator>(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1, class _Iter2> - friend - bool - operator>=(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1, class _Iter2> - friend - bool - operator<=(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1, class _Iter2> - friend - typename __debug_iter<_Cp, _Iter1>::difference_type - operator-(const __debug_iter<_Cp, _Iter1>&, const __debug_iter<_Cp, _Iter2>&); - - template <class _Cp, class _Iter1> - friend - __debug_iter<_Cp, _Iter1> - operator+(typename __debug_iter<_Cp, _Iter1>::difference_type, const __debug_iter<_Cp, _Iter1>&); -}; - -template <class _Container, class _Iter> -__debug_iter<_Container, _Iter>& -__debug_iter<_Container, _Iter>::operator=(const __debug_iter& __x) -{ - if (this != &__x) - { - __remove_owner(); - __i = __x.__i; - __set_owner(__x.__cont); - } - return *this; -} - -template <class _Container, class _Iter> -void -__debug_iter<_Container, _Iter>::__set_owner(const __container_type* __c) -{ - __cont = const_cast<__container_type*>(__c); - __debug_iter*& __head = __cont->__get_iterator_list(this); - __next = __head; - __head = this; -} - -template <class _Container, class _Iter> -void -__debug_iter<_Container, _Iter>::__remove_owner() -{ - if (__cont) - { - __debug_iter*& __head = __cont->__get_iterator_list(this); - if (__head == this) - __head = __next; - else - { - __debug_iter* __prev = __head; - for (__debug_iter* __p = __head->__next; __p != this; __p = __p->__next) - __prev = __p; - __prev->__next = __next; - } - __cont = 0; - } -} - -template <class _Container, class _Iter> -void -__debug_iter<_Container, _Iter>::__remove_all(__container_type* __c) -{ - __debug_iter*& __head = __c->__get_iterator_list((__debug_iter*)0); - __debug_iter* __p = __head; - __head = 0; - while (__p) - { - __p->__cont = 0; - __debug_iter* __n = __p->__next; - __p->__next = 0; - __p = __n; - } -} - -template <class _Container, class _Iter> -void -__debug_iter<_Container, _Iter>::swap(__container_type* __x, __container_type* __y) -{ - __debug_iter*& __head_x = __x->__get_iterator_list((__debug_iter*)0); - __debug_iter*& __head_y = __y->__get_iterator_list((__debug_iter*)0); - __debug_iter* __p = __head_x; - __head_x = __head_y; - __head_y = __p; - for (__p = __head_x; __p; __p = __p->__next) - __p->__cont = __x; - for (__p = __head_y; __p; __p = __p->__next) - __p->__cont = __y; -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__is_deref(false_type) const -{ - if (__cont == 0) - return false; - return __i != __cont->end().base(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__is_deref(true_type) const -{ - if (__cont == 0) - return false; - return __i < __cont->end().base(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_decrement(integral_constant<int, 0>) const -{ - if (__cont == 0) - return false; - return __i != __cont->begin().base(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_decrement(integral_constant<int, 1>) const -{ - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - return __b < __i && __i <= __b + __cont->size(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_decrement(integral_constant<int, 2>) const -{ - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - return __b < __i && __i <= __b + __cont->size(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_increment(integral_constant<int, 0>) const -{ - if (__cont == 0) - return false; - return __i != __cont->end().base(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_increment(integral_constant<int, 1>) const -{ - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - return __b <= __i && __i < __b + __cont->size(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_increment(integral_constant<int, 2>) const -{ - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - return __b <= __i && __i < __b + __cont->size(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_add(difference_type __n, false_type) const -{ - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - iterator_type __j = __i + __n; - return __b <= __j && __j <= __b + __cont->size(); -} - -template <class _Container, class _Iter> -bool -__debug_iter<_Container, _Iter>::__can_add(difference_type __n, true_type) const -{ - if (__cont == 0) - return false; - iterator_type __b = __cont->begin().base(); - iterator_type __j = __i + __n; - return __b <= __j && __j <= __b + __cont->size(); -} - -template <class _Container, class _Iter> -__debug_iter<_Container, _Iter>& -__debug_iter<_Container, _Iter>::operator+=(difference_type __n) -{ - assert(__can_add(__n)); - __i += __n; - return *this; -} +#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN) -template <class _Container, class _Iter1, class _Iter2> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -bool -operator==(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +auto +begin(_Cp& __c) -> decltype(__c.begin()) { - assert(__x.__cont && __x.__cont == __y.__cont); - return __x.base() == __y.base(); + return __c.begin(); } -template <class _Container, class _Iter1, class _Iter2> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -bool -operator!=(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +auto +begin(const _Cp& __c) -> decltype(__c.begin()) { - return !(__x == __y); + return __c.begin(); } -template <class _Container, class _Iter1, class _Iter2> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -bool -operator<(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +auto +end(_Cp& __c) -> decltype(__c.end()) { - assert(__x.__cont && __x.__cont == __y.__cont); - return __x.base() < __y.base(); + return __c.end(); } -template <class _Container, class _Iter1, class _Iter2> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -bool -operator>(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +auto +end(const _Cp& __c) -> decltype(__c.end()) { - return __y < __x; + return __c.end(); } -template <class _Container, class _Iter1, class _Iter2> +#if _LIBCPP_STD_VER > 11 + +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -bool -operator>=(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +auto cbegin(const _Cp& __c) -> decltype(begin(__c)) { - return !(__x < __y); + return __c.begin(); } -template <class _Container, class _Iter1, class _Iter2> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -bool -operator<=(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +auto cend(const _Cp& __c) -> decltype(end(__c)) { - return !(__y < __x); + return __c.end(); } -template <class _Container, class _Iter1, class _Iter2> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -typename __debug_iter<_Container, _Iter1>::difference_type -operator-(const __debug_iter<_Container, _Iter1>& __x, const __debug_iter<_Container, _Iter2>& __y) +auto rbegin(_Cp& __c) -> decltype(__c.rbegin()) { - assert(__x.__cont && __x.__cont == __y.__cont); - return __x.base() - __y.base(); + return __c.rbegin(); } -template <class _Container, class _Iter> +template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -__debug_iter<_Container, _Iter> -operator+(typename __debug_iter<_Container, _Iter>::difference_type __n, - const __debug_iter<_Container, _Iter>& __x) +auto rbegin(const _Cp& __c) -> decltype(__c.rbegin()) { - return __x + __n; + return __c.rbegin(); } -#endif // _LIBCPP_DEBUG - -#if !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN) - template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -auto -begin(_Cp& __c) -> decltype(__c.begin()) +auto rend(_Cp& __c) -> decltype(__c.rend()) { - return __c.begin(); + return __c.rend(); } template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -auto -begin(const _Cp& __c) -> decltype(__c.begin()) +auto rend(const _Cp& __c) -> decltype(__c.rend()) { - return __c.begin(); + return __c.rend(); } template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -auto -end(_Cp& __c) -> decltype(__c.end()) +auto crbegin(const _Cp& __c) -> decltype(rbegin(__c)) { - return __c.end(); + return rbegin(__c); } template <class _Cp> inline _LIBCPP_INLINE_VISIBILITY -auto -end(const _Cp& __c) -> decltype(__c.end()) +auto crend(const _Cp& __c) -> decltype(rend(__c)) { - return __c.end(); + return rend(__c); } +#endif + + #else // !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) && !defined(_LIBCPP_HAS_NO_TRAILING_RETURN) template <class _Cp> @@ -1872,6 +1532,37 @@ end(_Tp (&__array)[_Np]) return __array + _Np; } +#if _LIBCPP_STD_VER > 11 +template <class _Tp, size_t _Np> +inline _LIBCPP_INLINE_VISIBILITY +reverse_iterator<_Tp*> rbegin(_Tp (&__array)[_Np]) +{ + return reverse_iterator<_Tp*>(__array + _Np); +} + +template <class _Tp, size_t _Np> +inline _LIBCPP_INLINE_VISIBILITY +reverse_iterator<_Tp*> rend(_Tp (&__array)[_Np]) +{ + return reverse_iterator<_Tp*>(__array); +} + +template <class _Ep> +inline _LIBCPP_INLINE_VISIBILITY +reverse_iterator<const _Ep*> rbegin(initializer_list<_Ep> __il) +{ + return reverse_iterator<const _Ep*>(__il.end()); +} + +template <class _Ep> +inline _LIBCPP_INLINE_VISIBILITY +reverse_iterator<const _Ep*> rend(initializer_list<_Ep> __il) +{ + return reverse_iterator<const _Ep*>(__il.begin()); +} + +#endif + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_ITERATOR diff --git a/system/include/libcxx/limits b/system/include/libcxx/limits index c995ef59..d917c577 100644 --- a/system/include/libcxx/limits +++ b/system/include/libcxx/limits @@ -115,6 +115,10 @@ template<> class numeric_limits<cv long double>; #include "support/win32/limits_win32.h" #endif // _LIBCPP_MSVCRT +#if defined(__IBMCPP__) +#include "support/ibm/limits.h" +#endif // __IBMCPP__ + _LIBCPP_BEGIN_NAMESPACE_STD enum float_round_style @@ -433,7 +437,7 @@ protected: }; template <class _Tp> -class _LIBCPP_TYPE_VIS numeric_limits +class _LIBCPP_TYPE_VIS_ONLY numeric_limits : private __libcpp_numeric_limits<typename remove_cv<_Tp>::type> { typedef __libcpp_numeric_limits<typename remove_cv<_Tp>::type> __base; @@ -526,7 +530,7 @@ template <class _Tp> _LIBCPP_CONSTEXPR const float_round_style numeric_limits<_Tp>::round_style; template <class _Tp> -class _LIBCPP_TYPE_VIS numeric_limits<const _Tp> +class _LIBCPP_TYPE_VIS_ONLY numeric_limits<const _Tp> : private numeric_limits<_Tp> { typedef numeric_limits<_Tp> __base; @@ -619,7 +623,7 @@ template <class _Tp> _LIBCPP_CONSTEXPR const float_round_style numeric_limits<const _Tp>::round_style; template <class _Tp> -class _LIBCPP_TYPE_VIS numeric_limits<volatile _Tp> +class _LIBCPP_TYPE_VIS_ONLY numeric_limits<volatile _Tp> : private numeric_limits<_Tp> { typedef numeric_limits<_Tp> __base; @@ -712,7 +716,7 @@ template <class _Tp> _LIBCPP_CONSTEXPR const float_round_style numeric_limits<volatile _Tp>::round_style; template <class _Tp> -class _LIBCPP_TYPE_VIS numeric_limits<const volatile _Tp> +class _LIBCPP_TYPE_VIS_ONLY numeric_limits<const volatile _Tp> : private numeric_limits<_Tp> { typedef numeric_limits<_Tp> __base; diff --git a/system/include/libcxx/list b/system/include/libcxx/list index 4b1272a8..800a1a3f 100644 --- a/system/include/libcxx/list +++ b/system/include/libcxx/list @@ -40,6 +40,7 @@ public: noexcept(is_nothrow_default_constructible<allocator_type>::value); explicit list(const allocator_type& a); explicit list(size_type n); + explicit list(size_type n, const allocator_type& a); // C++14 list(size_type n, const value_type& value); list(size_type n, const value_type& value, const allocator_type& a); template <class Iter> @@ -178,7 +179,7 @@ template <class T, class Alloc> #include <__undef_min_max> -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG # include <__debug> #else # define _LIBCPP_ASSERT(x, m) ((void)0) @@ -226,12 +227,12 @@ struct __list_node _Tp __value_; }; -template <class _Tp, class _Alloc> class _LIBCPP_TYPE_VIS list; +template <class _Tp, class _Alloc> class _LIBCPP_TYPE_VIS_ONLY list; template <class _Tp, class _Alloc> class __list_imp; -template <class _Tp, class _VoidPtr> class _LIBCPP_TYPE_VIS __list_const_iterator; +template <class _Tp, class _VoidPtr> class _LIBCPP_TYPE_VIS_ONLY __list_const_iterator; template <class _Tp, class _VoidPtr> -class _LIBCPP_TYPE_VIS __list_iterator +class _LIBCPP_TYPE_VIS_ONLY __list_iterator { typedef typename pointer_traits<_VoidPtr>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES @@ -364,7 +365,7 @@ public: }; template <class _Tp, class _VoidPtr> -class _LIBCPP_TYPE_VIS __list_const_iterator +class _LIBCPP_TYPE_VIS_ONLY __list_const_iterator { typedef typename pointer_traits<_VoidPtr>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES @@ -806,7 +807,7 @@ __list_imp<_Tp, _Alloc>::swap(__list_imp& __c) } template <class _Tp, class _Alloc = allocator<_Tp> > -class _LIBCPP_TYPE_VIS list +class _LIBCPP_TYPE_VIS_ONLY list : private __list_imp<_Tp, _Alloc> { typedef __list_imp<_Tp, _Alloc> base; @@ -842,13 +843,16 @@ public: #endif } _LIBCPP_INLINE_VISIBILITY - list(const allocator_type& __a) : base(__a) + explicit list(const allocator_type& __a) : base(__a) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); #endif } - list(size_type __n); + explicit list(size_type __n); +#if _LIBCPP_STD_VER > 11 + explicit list(size_type __n, const allocator_type& __a); +#endif list(size_type __n, const value_type& __x); list(size_type __n, const value_type& __x, const allocator_type& __a); template <class _InpIter> @@ -1100,6 +1104,22 @@ list<_Tp, _Alloc>::list(size_type __n) #endif } +#if _LIBCPP_STD_VER > 11 +template <class _Tp, class _Alloc> +list<_Tp, _Alloc>::list(size_type __n, const allocator_type& __a) : base(__a) +{ +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif + for (; __n > 0; --__n) +#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + emplace_back(); +#else + push_back(value_type()); +#endif +} +#endif + template <class _Tp, class _Alloc> list<_Tp, _Alloc>::list(size_type __n, const value_type& __x) { diff --git a/system/include/libcxx/locale b/system/include/libcxx/locale index f5f5fff9..ac3ae7ea 100644 --- a/system/include/libcxx/locale +++ b/system/include/libcxx/locale @@ -93,10 +93,12 @@ public: typedef typename Codecvt::state_type state_type; typedef typename wide_string::traits_type::int_type int_type; - wstring_convert(Codecvt* pcvt = new Codecvt); + explicit wstring_convert(Codecvt* pcvt = new Codecvt); // explicit in C++14 wstring_convert(Codecvt* pcvt, state_type state); - wstring_convert(const byte_string& byte_err, + explicit wstring_convert(const byte_string& byte_err, // explicit in C++14 const wide_string& wide_err = wide_string()); + wstring_convert(const wstring_convert&) = delete; // C++14 + wstring_convert & operator=(const wstring_convert &) = delete; // C++14 ~wstring_convert(); wide_string from_bytes(char byte); @@ -109,7 +111,7 @@ public: byte_string to_bytes(const wide_string& wstr); byte_string to_bytes(const Elem* first, const Elem* last); - size_t converted() const; + size_t converted() const; // noexcept in C++14 state_type state() const; }; @@ -120,9 +122,12 @@ class wbuffer_convert public: typedef typename Tr::state_type state_type; - wbuffer_convert(streambuf* bytebuf = 0, Codecvt* pcvt = new Codecvt, - state_type state = state_type()); - + explicit wbuffer_convert(streambuf* bytebuf = 0, Codecvt* pcvt = new Codecvt, + state_type state = state_type()); // explicit in C++14 + wbuffer_convert(const wbuffer_convert&) = delete; // C++14 + wbuffer_convert & operator=(const wbuffer_convert &) = delete; // C++14 + ~wbuffer_convert(); // C++14 + streambuf* rdbuf() const; streambuf* rdbuf(streambuf* bytebuf); @@ -186,7 +191,7 @@ template <class charT> class messages_byname; #endif #include <cstdlib> #include <ctime> -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) #include <support/win32/locale_win32.h> #else // _LIBCPP_MSVCRT #include <nl_types.h> @@ -211,7 +216,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD #else # define _LIBCPP_GET_C_LOCALE __cloc() // Get the C locale object - locale_t __cloc(); + _LIBCPP_FUNC_VIS locale_t __cloc(); #define __cloc_defined #endif @@ -224,7 +229,7 @@ typedef _VSTD::unique_ptr<__locale_struct, decltype(&uselocale)> __locale_raii; // OSX has nice foo_l() functions that let you turn off use of the global // locale. Linux, not so much. The following functions avoid the locale when // that's possible and otherwise do the wrong thing. FIXME. -#if defined(__linux__) || defined(__EMSCRIPTEN__) +#if defined(__linux__) || defined(__EMSCRIPTEN__) || defined(_AIX) #ifdef _LIBCPP_LOCALE__L_EXTENSIONS decltype(MB_CUR_MAX_L(_VSTD::declval<locale_t>())) @@ -234,7 +239,7 @@ __mb_cur_max_l(locale_t __l) return MB_CUR_MAX_L(__l); } #else // _LIBCPP_LOCALE__L_EXTENSIONS -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE decltype(MB_CUR_MAX) __mb_cur_max_l(locale_t __l) { __locale_raii __current(uselocale(__l), uselocale); @@ -242,7 +247,7 @@ decltype(MB_CUR_MAX) __mb_cur_max_l(locale_t __l) } #endif // _LIBCPP_LOCALE__L_EXTENSIONS -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE wint_t __btowc_l(int __c, locale_t __l) { #ifdef _LIBCPP_LOCALE__L_EXTENSIONS @@ -253,7 +258,7 @@ wint_t __btowc_l(int __c, locale_t __l) #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE int __wctob_l(wint_t __c, locale_t __l) { #ifdef _LIBCPP_LOCALE__L_EXTENSIONS @@ -264,7 +269,7 @@ int __wctob_l(wint_t __c, locale_t __l) #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE size_t __wcsnrtombs_l(char *__dest, const wchar_t **__src, size_t __nwc, size_t __len, mbstate_t *__ps, locale_t __l) { @@ -276,7 +281,7 @@ size_t __wcsnrtombs_l(char *__dest, const wchar_t **__src, size_t __nwc, #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE size_t __wcrtomb_l(char *__s, wchar_t __wc, mbstate_t *__ps, locale_t __l) { #ifdef _LIBCPP_LOCALE__L_EXTENSIONS @@ -287,7 +292,7 @@ size_t __wcrtomb_l(char *__s, wchar_t __wc, mbstate_t *__ps, locale_t __l) #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE size_t __mbsnrtowcs_l(wchar_t * __dest, const char **__src, size_t __nms, size_t __len, mbstate_t *__ps, locale_t __l) { @@ -299,7 +304,7 @@ size_t __mbsnrtowcs_l(wchar_t * __dest, const char **__src, size_t __nms, #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE size_t __mbrtowc_l(wchar_t *__pwc, const char *__s, size_t __n, mbstate_t *__ps, locale_t __l) { @@ -311,7 +316,7 @@ size_t __mbrtowc_l(wchar_t *__pwc, const char *__s, size_t __n, #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE int __mbtowc_l(wchar_t *__pwc, const char *__pmb, size_t __max, locale_t __l) { #ifdef _LIBCPP_LOCALE__L_EXTENSIONS @@ -322,7 +327,7 @@ int __mbtowc_l(wchar_t *__pwc, const char *__pmb, size_t __max, locale_t __l) #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE size_t __mbrlen_l(const char *__s, size_t __n, mbstate_t *__ps, locale_t __l) { #ifdef _LIBCPP_LOCALE__L_EXTENSIONS @@ -333,7 +338,7 @@ size_t __mbrlen_l(const char *__s, size_t __n, mbstate_t *__ps, locale_t __l) #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE lconv *__localeconv_l(locale_t __l) { #ifdef _LIBCPP_LOCALE__L_EXTENSIONS @@ -344,7 +349,7 @@ lconv *__localeconv_l(locale_t __l) #endif } -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE size_t __mbsrtowcs_l(wchar_t *__dest, const char **__src, size_t __len, mbstate_t *__ps, locale_t __l) { @@ -528,7 +533,7 @@ __scan_keyword(_InputIterator& __b, _InputIterator __e, return __kb; } -struct __num_get_base +struct _LIBCPP_TYPE_VIS __num_get_base { static const int __num_get_buf_sz = 40; @@ -536,6 +541,7 @@ struct __num_get_base static const char __src[33]; }; +_LIBCPP_FUNC_VIS void __check_grouping(const string& __grouping, unsigned* __g, unsigned* __g_end, ios_base::iostate& __err); @@ -686,11 +692,11 @@ __num_get<_CharT>::__stage2_float_loop(_CharT __ct, bool& __in_units, char& __ex return 0; } -_LIBCPP_EXTERN_TEMPLATE(struct __num_get<char>) -_LIBCPP_EXTERN_TEMPLATE(struct __num_get<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_get<char>) +_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_get<wchar_t>) template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > -class _LIBCPP_TYPE_VIS num_get +class _LIBCPP_TYPE_VIS_ONLY num_get : public locale::facet, private __num_get<_CharT> { @@ -785,26 +791,61 @@ protected: _LIBCPP_ALWAYS_INLINE ~num_get() {} + template <class _Fp> + iter_type __do_get_floating_point + (iter_type __b, iter_type __e, ios_base& __iob, + ios_base::iostate& __err, _Fp& __v) const; + + template <class _Signed> + iter_type __do_get_signed + (iter_type __b, iter_type __e, ios_base& __iob, + ios_base::iostate& __err, _Signed& __v) const; + + template <class _Unsigned> + iter_type __do_get_unsigned + (iter_type __b, iter_type __e, ios_base& __iob, + ios_base::iostate& __err, _Unsigned& __v) const; + + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, bool& __v) const; + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, long& __v) const; + ios_base::iostate& __err, long& __v) const + { return this->__do_get_signed ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, long long& __v) const; + ios_base::iostate& __err, long long& __v) const + { return this->__do_get_signed ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, unsigned short& __v) const; + ios_base::iostate& __err, unsigned short& __v) const + { return this->__do_get_unsigned ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, unsigned int& __v) const; + ios_base::iostate& __err, unsigned int& __v) const + { return this->__do_get_unsigned ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, unsigned long& __v) const; + ios_base::iostate& __err, unsigned long& __v) const + { return this->__do_get_unsigned ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, unsigned long long& __v) const; + ios_base::iostate& __err, unsigned long long& __v) const + { return this->__do_get_unsigned ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, float& __v) const; + ios_base::iostate& __err, float& __v) const + { return this->__do_get_floating_point ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, double& __v) const; + ios_base::iostate& __err, double& __v) const + { return this->__do_get_floating_point ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, - ios_base::iostate& __err, long double& __v) const; + ios_base::iostate& __err, long double& __v) const + { return this->__do_get_floating_point ( __b, __e, __iob, __err, __v ); } + virtual iter_type do_get(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, void*& __v) const; }; @@ -946,153 +987,15 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, return __b; } -template <class _CharT, class _InputIterator> -_InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, - ios_base& __iob, - ios_base::iostate& __err, - long& __v) const -{ - // Stage 1 - int __base = this->__get_base(__iob); - // Stage 2 - char_type __atoms[26]; - char_type __thousands_sep; - string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep); - string __buf; - __buf.resize(__buf.capacity()); - char* __a = &__buf[0]; - char* __a_end = __a; - unsigned __g[__num_get_base::__num_get_buf_sz]; - unsigned* __g_end = __g; - unsigned __dc = 0; - for (; __b != __e; ++__b) - { - if (__a_end - __a == __buf.size()) - { - size_t __tmp = __buf.size(); - __buf.resize(2*__buf.size()); - __buf.resize(__buf.capacity()); - __a = &__buf[0]; - __a_end = __a + __tmp; - } - if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc, - __thousands_sep, __grouping, __g, __g_end, - __atoms)) - break; - } - if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz) - *__g_end++ = __dc; - // Stage 3 - __v = __num_get_signed_integral<long>(__a, __a_end, __err, __base); - // Digit grouping checked - __check_grouping(__grouping, __g, __g_end, __err); - // EOF checked - if (__b == __e) - __err |= ios_base::eofbit; - return __b; -} - -template <class _CharT, class _InputIterator> -_InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, - ios_base& __iob, - ios_base::iostate& __err, - long long& __v) const -{ - // Stage 1 - int __base = this->__get_base(__iob); - // Stage 2 - char_type __atoms[26]; - char_type __thousands_sep; - string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep); - string __buf; - __buf.resize(__buf.capacity()); - char* __a = &__buf[0]; - char* __a_end = __a; - unsigned __g[__num_get_base::__num_get_buf_sz]; - unsigned* __g_end = __g; - unsigned __dc = 0; - for (; __b != __e; ++__b) - { - if (__a_end - __a == __buf.size()) - { - size_t __tmp = __buf.size(); - __buf.resize(2*__buf.size()); - __buf.resize(__buf.capacity()); - __a = &__buf[0]; - __a_end = __a + __tmp; - } - if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc, - __thousands_sep, __grouping, __g, __g_end, - __atoms)) - break; - } - if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz) - *__g_end++ = __dc; - // Stage 3 - __v = __num_get_signed_integral<long long>(__a, __a_end, __err, __base); - // Digit grouping checked - __check_grouping(__grouping, __g, __g_end, __err); - // EOF checked - if (__b == __e) - __err |= ios_base::eofbit; - return __b; -} - -template <class _CharT, class _InputIterator> -_InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, - ios_base& __iob, - ios_base::iostate& __err, - unsigned short& __v) const -{ - // Stage 1 - int __base = this->__get_base(__iob); - // Stage 2 - char_type __atoms[26]; - char_type __thousands_sep; - string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep); - string __buf; - __buf.resize(__buf.capacity()); - char* __a = &__buf[0]; - char* __a_end = __a; - unsigned __g[__num_get_base::__num_get_buf_sz]; - unsigned* __g_end = __g; - unsigned __dc = 0; - for (; __b != __e; ++__b) - { - if (__a_end - __a == __buf.size()) - { - size_t __tmp = __buf.size(); - __buf.resize(2*__buf.size()); - __buf.resize(__buf.capacity()); - __a = &__buf[0]; - __a_end = __a + __tmp; - } - if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc, - __thousands_sep, __grouping, __g, __g_end, - __atoms)) - break; - } - if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz) - *__g_end++ = __dc; - // Stage 3 - __v = __num_get_unsigned_integral<unsigned short>(__a, __a_end, __err, __base); - // Digit grouping checked - __check_grouping(__grouping, __g, __g_end, __err); - // EOF checked - if (__b == __e) - __err |= ios_base::eofbit; - return __b; -} +// signed template <class _CharT, class _InputIterator> +template <class _Signed> _InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, +num_get<_CharT, _InputIterator>::__do_get_signed(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, - unsigned int& __v) const + _Signed& __v) const { // Stage 1 int __base = this->__get_base(__iob); @@ -1125,7 +1028,7 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz) *__g_end++ = __dc; // Stage 3 - __v = __num_get_unsigned_integral<unsigned int>(__a, __a_end, __err, __base); + __v = __num_get_signed_integral<_Signed>(__a, __a_end, __err, __base); // Digit grouping checked __check_grouping(__grouping, __g, __g_end, __err); // EOF checked @@ -1134,59 +1037,15 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, return __b; } -template <class _CharT, class _InputIterator> -_InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, - ios_base& __iob, - ios_base::iostate& __err, - unsigned long& __v) const -{ - // Stage 1 - int __base = this->__get_base(__iob); - // Stage 2 - char_type __atoms[26]; - char_type __thousands_sep; - string __grouping = this->__stage2_int_prep(__iob, __atoms, __thousands_sep); - string __buf; - __buf.resize(__buf.capacity()); - char* __a = &__buf[0]; - char* __a_end = __a; - unsigned __g[__num_get_base::__num_get_buf_sz]; - unsigned* __g_end = __g; - unsigned __dc = 0; - for (; __b != __e; ++__b) - { - if (__a_end - __a == __buf.size()) - { - size_t __tmp = __buf.size(); - __buf.resize(2*__buf.size()); - __buf.resize(__buf.capacity()); - __a = &__buf[0]; - __a_end = __a + __tmp; - } - if (this->__stage2_int_loop(*__b, __base, __a, __a_end, __dc, - __thousands_sep, __grouping, __g, __g_end, - __atoms)) - break; - } - if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz) - *__g_end++ = __dc; - // Stage 3 - __v = __num_get_unsigned_integral<unsigned long>(__a, __a_end, __err, __base); - // Digit grouping checked - __check_grouping(__grouping, __g, __g_end, __err); - // EOF checked - if (__b == __e) - __err |= ios_base::eofbit; - return __b; -} +// unsigned template <class _CharT, class _InputIterator> +template <class _Unsigned> _InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, +num_get<_CharT, _InputIterator>::__do_get_unsigned(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, - unsigned long long& __v) const + _Unsigned& __v) const { // Stage 1 int __base = this->__get_base(__iob); @@ -1219,59 +1078,7 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, if (__grouping.size() != 0 && __g_end-__g < __num_get_base::__num_get_buf_sz) *__g_end++ = __dc; // Stage 3 - __v = __num_get_unsigned_integral<unsigned long long>(__a, __a_end, __err, __base); - // Digit grouping checked - __check_grouping(__grouping, __g, __g_end, __err); - // EOF checked - if (__b == __e) - __err |= ios_base::eofbit; - return __b; -} - -template <class _CharT, class _InputIterator> -_InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, - ios_base& __iob, - ios_base::iostate& __err, - float& __v) const -{ - // Stage 1, nothing to do - // Stage 2 - char_type __atoms[32]; - char_type __decimal_point; - char_type __thousands_sep; - string __grouping = this->__stage2_float_prep(__iob, __atoms, - __decimal_point, - __thousands_sep); - string __buf; - __buf.resize(__buf.capacity()); - char* __a = &__buf[0]; - char* __a_end = __a; - unsigned __g[__num_get_base::__num_get_buf_sz]; - unsigned* __g_end = __g; - unsigned __dc = 0; - bool __in_units = true; - char __exp = 'E'; - for (; __b != __e; ++__b) - { - if (__a_end - __a == __buf.size()) - { - size_t __tmp = __buf.size(); - __buf.resize(2*__buf.size()); - __buf.resize(__buf.capacity()); - __a = &__buf[0]; - __a_end = __a + __tmp; - } - if (this->__stage2_float_loop(*__b, __in_units, __exp, __a, __a_end, - __decimal_point, __thousands_sep, - __grouping, __g, __g_end, - __dc, __atoms)) - break; - } - if (__grouping.size() != 0 && __in_units && __g_end-__g < __num_get_base::__num_get_buf_sz) - *__g_end++ = __dc; - // Stage 3 - __v = __num_get_float<float>(__a, __a_end, __err); + __v = __num_get_unsigned_integral<_Unsigned>(__a, __a_end, __err, __base); // Digit grouping checked __check_grouping(__grouping, __g, __g_end, __err); // EOF checked @@ -1280,64 +1087,15 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, return __b; } -template <class _CharT, class _InputIterator> -_InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, - ios_base& __iob, - ios_base::iostate& __err, - double& __v) const -{ - // Stage 1, nothing to do - // Stage 2 - char_type __atoms[32]; - char_type __decimal_point; - char_type __thousands_sep; - string __grouping = this->__stage2_float_prep(__iob, __atoms, - __decimal_point, - __thousands_sep); - string __buf; - __buf.resize(__buf.capacity()); - char* __a = &__buf[0]; - char* __a_end = __a; - unsigned __g[__num_get_base::__num_get_buf_sz]; - unsigned* __g_end = __g; - unsigned __dc = 0; - bool __in_units = true; - char __exp = 'E'; - for (; __b != __e; ++__b) - { - if (__a_end - __a == __buf.size()) - { - size_t __tmp = __buf.size(); - __buf.resize(2*__buf.size()); - __buf.resize(__buf.capacity()); - __a = &__buf[0]; - __a_end = __a + __tmp; - } - if (this->__stage2_float_loop(*__b, __in_units, __exp, __a, __a_end, - __decimal_point, __thousands_sep, - __grouping, __g, __g_end, - __dc, __atoms)) - break; - } - if (__grouping.size() != 0 && __in_units && __g_end-__g < __num_get_base::__num_get_buf_sz) - *__g_end++ = __dc; - // Stage 3 - __v = __num_get_float<double>(__a, __a_end, __err); - // Digit grouping checked - __check_grouping(__grouping, __g, __g_end, __err); - // EOF checked - if (__b == __e) - __err |= ios_base::eofbit; - return __b; -} +// floating point template <class _CharT, class _InputIterator> +template <class _Fp> _InputIterator -num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, +num_get<_CharT, _InputIterator>::__do_get_floating_point(iter_type __b, iter_type __e, ios_base& __iob, ios_base::iostate& __err, - long double& __v) const + _Fp& __v) const { // Stage 1, nothing to do // Stage 2 @@ -1375,7 +1133,7 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, if (__grouping.size() != 0 && __in_units && __g_end-__g < __num_get_base::__num_get_buf_sz) *__g_end++ = __dc; // Stage 3 - __v = __num_get_float<long double>(__a, __a_end, __err); + __v = __num_get_float<_Fp>(__a, __a_end, __err); // Digit grouping checked __check_grouping(__grouping, __g, __g_end, __err); // EOF checked @@ -1435,10 +1193,10 @@ num_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, return __b; } -_LIBCPP_EXTERN_TEMPLATE(class num_get<char>) -_LIBCPP_EXTERN_TEMPLATE(class num_get<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_get<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_get<wchar_t>) -struct __num_put_base +struct _LIBCPP_TYPE_VIS __num_put_base { protected: static void __format_int(char* __fmt, const char* __len, bool __signd, @@ -1585,11 +1343,11 @@ __num_put<_CharT>::__widen_and_group_float(char* __nb, char* __np, char* __ne, __op = __ob + (__np - __nb); } -_LIBCPP_EXTERN_TEMPLATE(struct __num_put<char>) -_LIBCPP_EXTERN_TEMPLATE(struct __num_put<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_put<char>) +_LIBCPP_EXTERN_TEMPLATE2(struct _LIBCPP_TYPE_VIS __num_put<wchar_t>) template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > -class _LIBCPP_TYPE_VIS num_put +class _LIBCPP_TYPE_VIS_ONLY num_put : public locale::facet, private __num_put<_CharT> { @@ -1769,7 +1527,12 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, return do_put(__s, __iob, __fl, (unsigned long)__v); const numpunct<char_type>& __np = use_facet<numpunct<char_type> >(__iob.getloc()); typedef typename numpunct<char_type>::string_type string_type; +#if _LIBCPP_DEBUG_LEVEL >= 2 + string_type __tmp(__v ? __np.truename() : __np.falsename()); + string_type __nm = _VSTD::move(__tmp); +#else string_type __nm = __v ? __np.truename() : __np.falsename(); +#endif for (typename string_type::iterator __i = __nm.begin(); __i != __nm.end(); ++__i, ++__s) *__s = *__i; return __s; @@ -2065,8 +1828,8 @@ num_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base& __iob, return __pad_and_output(__s, __o, __op, __oe, __iob, __fl); } -_LIBCPP_EXTERN_TEMPLATE(class num_put<char>) -_LIBCPP_EXTERN_TEMPLATE(class num_put<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_put<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS num_put<wchar_t>) template <class _CharT, class _InputIterator> _LIBCPP_HIDDEN @@ -2108,7 +1871,7 @@ public: }; template <class _CharT> -class __time_get_c_storage // purposefully not decorated +class _LIBCPP_TYPE_VIS __time_get_c_storage { protected: typedef basic_string<_CharT> string_type; @@ -2123,7 +1886,7 @@ protected: }; template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > -class _LIBCPP_TYPE_VIS time_get +class _LIBCPP_TYPE_VIS_ONLY time_get : public locale::facet, public time_base, private __time_get_c_storage<_CharT> @@ -2732,10 +2495,10 @@ time_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, return __b; } -_LIBCPP_EXTERN_TEMPLATE(class time_get<char>) -_LIBCPP_EXTERN_TEMPLATE(class time_get<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get<wchar_t>) -class __time_get +class _LIBCPP_TYPE_VIS __time_get { protected: locale_t __loc_; @@ -2746,7 +2509,7 @@ protected: }; template <class _CharT> -class __time_get_storage +class _LIBCPP_TYPE_VIS __time_get_storage : public __time_get { protected: @@ -2773,7 +2536,7 @@ private: }; template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > -class _LIBCPP_TYPE_VIS time_get_byname +class _LIBCPP_TYPE_VIS_ONLY time_get_byname : public time_get<_CharT, _InputIterator>, private __time_get_storage<_CharT> { @@ -2815,10 +2578,10 @@ private: virtual const string_type& __X() const {return this->__X_;} }; -_LIBCPP_EXTERN_TEMPLATE(class time_get_byname<char>) -_LIBCPP_EXTERN_TEMPLATE(class time_get_byname<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get_byname<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_get_byname<wchar_t>) -class __time_put +class _LIBCPP_TYPE_VIS __time_put { locale_t __loc_; protected: @@ -2833,7 +2596,7 @@ protected: }; template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > -class _LIBCPP_TYPE_VIS time_put +class _LIBCPP_TYPE_VIS_ONLY time_put : public locale::facet, private __time_put { @@ -2928,11 +2691,11 @@ time_put<_CharT, _OutputIterator>::do_put(iter_type __s, ios_base&, return _VSTD::copy(__nb, __ne, __s); } -_LIBCPP_EXTERN_TEMPLATE(class time_put<char>) -_LIBCPP_EXTERN_TEMPLATE(class time_put<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put<wchar_t>) template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > -class _LIBCPP_TYPE_VIS time_put_byname +class _LIBCPP_TYPE_VIS_ONLY time_put_byname : public time_put<_CharT, _OutputIterator> { public: @@ -2949,8 +2712,8 @@ protected: ~time_put_byname() {} }; -_LIBCPP_EXTERN_TEMPLATE(class time_put_byname<char>) -_LIBCPP_EXTERN_TEMPLATE(class time_put_byname<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put_byname<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS time_put_byname<wchar_t>) // money_base @@ -2966,7 +2729,7 @@ public: // moneypunct template <class _CharT, bool _International = false> -class _LIBCPP_TYPE_VIS moneypunct +class _LIBCPP_TYPE_VIS_ONLY moneypunct : public locale::facet, public money_base { @@ -3016,15 +2779,15 @@ template <class _CharT, bool _International> const bool moneypunct<_CharT, _International>::intl; -_LIBCPP_EXTERN_TEMPLATE(class moneypunct<char, false>) -_LIBCPP_EXTERN_TEMPLATE(class moneypunct<char, true>) -_LIBCPP_EXTERN_TEMPLATE(class moneypunct<wchar_t, false>) -_LIBCPP_EXTERN_TEMPLATE(class moneypunct<wchar_t, true>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct<char, false>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct<char, true>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct<wchar_t, false>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct<wchar_t, true>) // moneypunct_byname template <class _CharT, bool _International = false> -class _LIBCPP_TYPE_VIS moneypunct_byname +class _LIBCPP_TYPE_VIS_ONLY moneypunct_byname : public moneypunct<_CharT, _International> { public: @@ -3073,10 +2836,10 @@ template<> void moneypunct_byname<char, true>::init(const char*); template<> void moneypunct_byname<wchar_t, false>::init(const char*); template<> void moneypunct_byname<wchar_t, true>::init(const char*); -_LIBCPP_EXTERN_TEMPLATE(class moneypunct_byname<char, false>) -_LIBCPP_EXTERN_TEMPLATE(class moneypunct_byname<char, true>) -_LIBCPP_EXTERN_TEMPLATE(class moneypunct_byname<wchar_t, false>) -_LIBCPP_EXTERN_TEMPLATE(class moneypunct_byname<wchar_t, true>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname<char, false>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname<char, true>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname<wchar_t, false>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS moneypunct_byname<wchar_t, true>) // money_get @@ -3132,11 +2895,11 @@ __money_get<_CharT>::__gather_info(bool __intl, const locale& __loc, } } -_LIBCPP_EXTERN_TEMPLATE(class __money_get<char>) -_LIBCPP_EXTERN_TEMPLATE(class __money_get<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_get<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_get<wchar_t>) template <class _CharT, class _InputIterator = istreambuf_iterator<_CharT> > -class _LIBCPP_TYPE_VIS money_get +class _LIBCPP_TYPE_VIS_ONLY money_get : public locale::facet, private __money_get<_CharT> { @@ -3190,7 +2953,7 @@ template <class _CharT, class _InputIterator> locale::id money_get<_CharT, _InputIterator>::id; -void __do_nothing(void*); +_LIBCPP_FUNC_VIS void __do_nothing(void*); template <class _Tp> _LIBCPP_HIDDEN @@ -3320,7 +3083,7 @@ money_get<_CharT, _InputIterator>::__do_get(iter_type& __b, iter_type __e, bool __more_needed = __trailing_sign || (__p < 2) || (__p == 2 && __pat.field[3] != static_cast<char>(money_base::none)); - bool __sb = __flags & ios_base::showbase; + bool __sb = (__flags & ios_base::showbase) != 0; if (__sb || __more_needed) { typename string_type::const_iterator __sym_space_end = __sym.begin(); @@ -3513,8 +3276,8 @@ money_get<_CharT, _InputIterator>::do_get(iter_type __b, iter_type __e, return __b; } -_LIBCPP_EXTERN_TEMPLATE(class money_get<char>) -_LIBCPP_EXTERN_TEMPLATE(class money_get<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_get<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_get<wchar_t>) // money_put @@ -3688,11 +3451,11 @@ __money_put<_CharT>::__format(char_type* __mb, char_type*& __mi, char_type*& __m __mi = __mb; } -_LIBCPP_EXTERN_TEMPLATE(class __money_put<char>) -_LIBCPP_EXTERN_TEMPLATE(class __money_put<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_put<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS __money_put<wchar_t>) template <class _CharT, class _OutputIterator = ostreambuf_iterator<_CharT> > -class _LIBCPP_TYPE_VIS money_put +class _LIBCPP_TYPE_VIS_ONLY money_put : public locale::facet, private __money_put<_CharT> { @@ -3845,8 +3608,8 @@ money_put<_CharT, _OutputIterator>::do_put(iter_type __s, bool __intl, return __pad_and_output(__s, __mb, __mi, __me, __iob, __fl); } -_LIBCPP_EXTERN_TEMPLATE(class money_put<char>) -_LIBCPP_EXTERN_TEMPLATE(class money_put<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_put<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS money_put<wchar_t>) // messages @@ -3859,7 +3622,7 @@ public: }; template <class _CharT> -class _LIBCPP_TYPE_VIS messages +class _LIBCPP_TYPE_VIS_ONLY messages : public locale::facet, public messages_base { @@ -3955,11 +3718,11 @@ messages<_CharT>::do_close(catalog __c) const #endif // !_WIN32 } -_LIBCPP_EXTERN_TEMPLATE(class messages<char>) -_LIBCPP_EXTERN_TEMPLATE(class messages<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages<wchar_t>) template <class _CharT> -class _LIBCPP_TYPE_VIS messages_byname +class _LIBCPP_TYPE_VIS_ONLY messages_byname : public messages<_CharT> { public: @@ -3979,13 +3742,13 @@ protected: ~messages_byname() {} }; -_LIBCPP_EXTERN_TEMPLATE(class messages_byname<char>) -_LIBCPP_EXTERN_TEMPLATE(class messages_byname<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages_byname<char>) +_LIBCPP_EXTERN_TEMPLATE2(class _LIBCPP_TYPE_VIS messages_byname<wchar_t>) template<class _Codecvt, class _Elem = wchar_t, class _Wide_alloc = allocator<_Elem>, class _Byte_alloc = allocator<char> > -class _LIBCPP_TYPE_VIS wstring_convert +class _LIBCPP_TYPE_VIS_ONLY wstring_convert { public: typedef basic_string<char, char_traits<char>, _Byte_alloc> byte_string; @@ -4003,9 +3766,9 @@ private: wstring_convert(const wstring_convert& __wc); wstring_convert& operator=(const wstring_convert& __wc); public: - wstring_convert(_Codecvt* __pcvt = new _Codecvt); + _LIBCPP_EXPLICIT_AFTER_CXX11 wstring_convert(_Codecvt* __pcvt = new _Codecvt); wstring_convert(_Codecvt* __pcvt, state_type __state); - wstring_convert(const byte_string& __byte_err, + _LIBCPP_EXPLICIT_AFTER_CXX11 wstring_convert(const byte_string& __byte_err, const wide_string& __wide_err = wide_string()); #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES wstring_convert(wstring_convert&& __wc); @@ -4035,7 +3798,7 @@ public: byte_string to_bytes(const _Elem* __first, const _Elem* __last); _LIBCPP_ALWAYS_INLINE - size_t converted() const {return __cvtcount_;} + size_t converted() const _NOEXCEPT {return __cvtcount_;} _LIBCPP_ALWAYS_INLINE state_type state() const {return __cvtstate_;} }; @@ -4238,7 +4001,7 @@ wstring_convert<_Codecvt, _Elem, _Wide_alloc, _Byte_alloc>:: } template <class _Codecvt, class _Elem = wchar_t, class _Tr = char_traits<_Elem> > -class _LIBCPP_TYPE_VIS wbuffer_convert +class _LIBCPP_TYPE_VIS_ONLY wbuffer_convert : public basic_streambuf<_Elem, _Tr> { public: @@ -4269,8 +4032,8 @@ private: wbuffer_convert(const wbuffer_convert&); wbuffer_convert& operator=(const wbuffer_convert&); public: - wbuffer_convert(streambuf* __bytebuf = 0, _Codecvt* __pcvt = new _Codecvt, - state_type __state = state_type()); + _LIBCPP_EXPLICIT_AFTER_CXX11 wbuffer_convert(streambuf* __bytebuf = 0, + _Codecvt* __pcvt = new _Codecvt, state_type __state = state_type()); ~wbuffer_convert(); _LIBCPP_INLINE_VISIBILITY diff --git a/system/include/libcxx/map b/system/include/libcxx/map index 953743a6..009e8e21 100644 --- a/system/include/libcxx/map +++ b/system/include/libcxx/map @@ -77,7 +77,12 @@ public: map(map&& m, const allocator_type& a); map(initializer_list<value_type> il, const key_compare& comp = key_compare()); map(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a); - ~map(); + template <class InputIterator> + map(InputIterator first, InputIterator last, const allocator_type& a) + : map(first, last, Compare(), a) {} // C++14 + map(initializer_list<value_type> il, const allocator_type& a) + : map(il, Compare(), a) {} // C++14 + ~map(); map& operator=(const map& m); map& operator=(map&& m) @@ -149,13 +154,34 @@ public: // map operations: iterator find(const key_type& k); const_iterator find(const key_type& k) const; + template<typename K> + iterator find(const K& x); // C++14 + template<typename K> + const_iterator find(const K& x) const; // C++14 + template<typename K> + size_type count(const K& x) const; + size_type count(const key_type& k) const; iterator lower_bound(const key_type& k); const_iterator lower_bound(const key_type& k) const; + template<typename K> + iterator lower_bound(const K& x); // C++14 + template<typename K> + const_iterator lower_bound(const K& x) const; // C++14 + iterator upper_bound(const key_type& k); const_iterator upper_bound(const key_type& k) const; + template<typename K> + iterator upper_bound(const K& x); // C++14 + template<typename K> + const_iterator upper_bound(const K& x) const; // C++14 + pair<iterator,iterator> equal_range(const key_type& k); pair<const_iterator,const_iterator> equal_range(const key_type& k) const; + template<typename K> + pair<iterator,iterator> equal_range(const K& x); // C++14 + template<typename K> + pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 }; template <class Key, class T, class Compare, class Allocator> @@ -252,6 +278,11 @@ public: multimap(initializer_list<value_type> il, const key_compare& comp = key_compare()); multimap(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a); + template <class InputIterator> + multimap(InputIterator first, InputIterator last, const allocator_type& a) + : multimap(first, last, Compare(), a) {} // C++14 + multimap(initializer_list<value_type> il, const allocator_type& a) + : multimap(il, Compare(), a) {} // C++14 ~multimap(); multimap& operator=(const multimap& m); @@ -317,13 +348,34 @@ public: // map operations: iterator find(const key_type& k); const_iterator find(const key_type& k) const; + template<typename K> + iterator find(const K& x); // C++14 + template<typename K> + const_iterator find(const K& x) const; // C++14 + template<typename K> + size_type count(const K& x) const; + size_type count(const key_type& k) const; iterator lower_bound(const key_type& k); const_iterator lower_bound(const key_type& k) const; + template<typename K> + iterator lower_bound(const K& x); // C++14 + template<typename K> + const_iterator lower_bound(const K& x) const; // C++14 + iterator upper_bound(const key_type& k); const_iterator upper_bound(const key_type& k) const; + template<typename K> + iterator upper_bound(const K& x); // C++14 + template<typename K> + const_iterator upper_bound(const K& x) const; // C++14 + pair<iterator,iterator> equal_range(const key_type& k); pair<const_iterator,const_iterator> equal_range(const key_type& k) const; + template<typename K> + pair<iterator,iterator> equal_range(const K& x); // C++14 + template<typename K> + pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 }; template <class Key, class T, class Compare, class Allocator> @@ -409,6 +461,20 @@ public: _LIBCPP_INLINE_VISIBILITY bool operator()(const _Key& __x, const _CP& __y) const {return static_cast<const _Compare&>(*this)(__x, __y.__cc.first);} + +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type + operator () ( const _K2& __x, const _CP& __y ) const + {return static_cast<const _Compare&>(*this) (__x, __y.__cc.first);} + + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type + operator () (const _CP& __x, const _K2& __y) const + {return static_cast<const _Compare&>(*this) (__x.__cc.first, __y);} +#endif }; template <class _Key, class _CP, class _Compare> @@ -437,6 +503,20 @@ public: _LIBCPP_INLINE_VISIBILITY bool operator()(const _Key& __x, const _CP& __y) const {return comp(__x, __y.__cc.first);} + +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type + operator () ( const _K2& __x, const _CP& __y ) const + {return comp (__x, __y.__cc.first);} + + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value, bool>::type + operator () (const _CP& __x, const _K2& __y) const + {return comp (__x.__cc.first, __y);} +#endif }; template <class _Allocator> @@ -495,8 +575,77 @@ template <class _Key, class _Tp, class _Compare, class _Allocator> class multimap; template <class _TreeIterator> class __map_const_iterator; +#if __cplusplus >= 201103L + +template <class _Key, class _Tp> +union __value_type +{ + typedef _Key key_type; + typedef _Tp mapped_type; + typedef pair<const key_type, mapped_type> value_type; + typedef pair<key_type, mapped_type> __nc_value_type; + + value_type __cc; + __nc_value_type __nc; + + template <class ..._Args> + _LIBCPP_INLINE_VISIBILITY + __value_type(_Args&& ...__args) + : __cc(std::forward<_Args>(__args)...) {} + + _LIBCPP_INLINE_VISIBILITY + __value_type(const __value_type& __v) + : __cc(__v.__cc) {} + + _LIBCPP_INLINE_VISIBILITY + __value_type(__value_type& __v) + : __cc(__v.__cc) {} + + _LIBCPP_INLINE_VISIBILITY + __value_type(__value_type&& __v) + : __nc(std::move(__v.__nc)) {} + + _LIBCPP_INLINE_VISIBILITY + __value_type& operator=(const __value_type& __v) + {__nc = __v.__cc; return *this;} + + _LIBCPP_INLINE_VISIBILITY + __value_type& operator=(__value_type&& __v) + {__nc = std::move(__v.__nc); return *this;} + + _LIBCPP_INLINE_VISIBILITY + ~__value_type() {__cc.~value_type();} +}; + +#else + +template <class _Key, class _Tp> +struct __value_type +{ + typedef _Key key_type; + typedef _Tp mapped_type; + typedef pair<const key_type, mapped_type> value_type; + + value_type __cc; + + _LIBCPP_INLINE_VISIBILITY + __value_type() {} + + template <class _A0> + _LIBCPP_INLINE_VISIBILITY + __value_type(const _A0& __a0) + : __cc(__a0) {} + + template <class _A0, class _A1> + _LIBCPP_INLINE_VISIBILITY + __value_type(const _A0& __a0, const _A1& __a1) + : __cc(__a0, __a1) {} +}; + +#endif + template <class _TreeIterator> -class _LIBCPP_TYPE_VIS __map_iterator +class _LIBCPP_TYPE_VIS_ONLY __map_iterator { _TreeIterator __i_; @@ -555,13 +704,13 @@ public: bool operator!=(const __map_iterator& __x, const __map_iterator& __y) {return __x.__i_ != __y.__i_;} - template <class, class, class, class> friend class _LIBCPP_TYPE_VIS map; - template <class, class, class, class> friend class _LIBCPP_TYPE_VIS multimap; - template <class> friend class _LIBCPP_TYPE_VIS __map_const_iterator; + template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY map; + template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multimap; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator; }; template <class _TreeIterator> -class _LIBCPP_TYPE_VIS __map_const_iterator +class _LIBCPP_TYPE_VIS_ONLY __map_const_iterator { _TreeIterator __i_; @@ -624,14 +773,14 @@ public: bool operator!=(const __map_const_iterator& __x, const __map_const_iterator& __y) {return __x.__i_ != __y.__i_;} - template <class, class, class, class> friend class _LIBCPP_TYPE_VIS map; - template <class, class, class, class> friend class _LIBCPP_TYPE_VIS multimap; - template <class, class, class> friend class _LIBCPP_TYPE_VIS __tree_const_iterator; + template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY map; + template <class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY multimap; + template <class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY __tree_const_iterator; }; template <class _Key, class _Tp, class _Compare = less<_Key>, class _Allocator = allocator<pair<const _Key, _Tp> > > -class _LIBCPP_TYPE_VIS map +class _LIBCPP_TYPE_VIS_ONLY map { public: // types: @@ -644,7 +793,7 @@ public: typedef value_type& reference; typedef const value_type& const_reference; - class _LIBCPP_TYPE_VIS value_compare + class _LIBCPP_TYPE_VIS_ONLY value_compare : public binary_function<value_type, value_type, bool> { friend class map; @@ -660,49 +809,7 @@ public: private: -#if __cplusplus >= 201103L - union __value_type - { - typedef typename map::value_type value_type; - typedef typename map::__nc_value_type __nc_value_type; - value_type __cc; - __nc_value_type __nc; - - template <class ..._Args> - __value_type(_Args&& ...__args) - : __cc(std::forward<_Args>(__args)...) {} - - __value_type(const __value_type& __v) - : __cc(std::move(__v.__cc)) {} - - __value_type(__value_type&& __v) - : __nc(std::move(__v.__nc)) {} - - __value_type& operator=(const __value_type& __v) - {__nc = __v.__cc; return *this;} - - __value_type& operator=(__value_type&& __v) - {__nc = std::move(__v.__nc); return *this;} - - ~__value_type() {__cc.~value_type();} - }; -#else - struct __value_type - { - typedef typename map::value_type value_type; - value_type __cc; - - __value_type() {} - - template <class _A0> - __value_type(const _A0& __a0) - : __cc(__a0) {} - - template <class _A0, class _A1> - __value_type(const _A0& __a0, const _A1& __a1) - : __cc(__a0, __a1) {} - }; -#endif + typedef _VSTD::__value_type<key_type, mapped_type> __value_type; typedef __map_value_compare<key_type, __value_type, key_compare> __vc; typedef typename allocator_traits<allocator_type>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES @@ -757,6 +864,13 @@ public: insert(__f, __l); } +#if _LIBCPP_STD_VER > 11 + template <class _InputIterator> + _LIBCPP_INLINE_VISIBILITY + map(_InputIterator __f, _InputIterator __l, const allocator_type& __a) + : map(__f, __l, key_compare(), __a) {} +#endif + _LIBCPP_INLINE_VISIBILITY map(const map& __m) : __tree_(__m.__tree_) @@ -815,6 +929,12 @@ public: insert(__il.begin(), __il.end()); } +#if _LIBCPP_STD_VER > 11 + _LIBCPP_INLINE_VISIBILITY + map(initializer_list<value_type> __il, const allocator_type& __a) + : map(__il, key_compare(), __a) {} +#endif + _LIBCPP_INLINE_VISIBILITY map& operator=(initializer_list<value_type> __il) { @@ -961,6 +1081,17 @@ public: iterator find(const key_type& __k) {return __tree_.find(__k);} _LIBCPP_INLINE_VISIBILITY const_iterator find(const key_type& __k) const {return __tree_.find(__k);} +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + find(const _K2& __k) {return __tree_.find(__k);} + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + find(const _K2& __k) const {return __tree_.find(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY size_type count(const key_type& __k) const {return __tree_.__count_unique(__k);} @@ -970,18 +1101,51 @@ public: _LIBCPP_INLINE_VISIBILITY const_iterator lower_bound(const key_type& __k) const {return __tree_.lower_bound(__k);} +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} + + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY iterator upper_bound(const key_type& __k) {return __tree_.upper_bound(__k);} _LIBCPP_INLINE_VISIBILITY const_iterator upper_bound(const key_type& __k) const {return __tree_.upper_bound(__k);} +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY pair<iterator,iterator> equal_range(const key_type& __k) {return __tree_.__equal_range_unique(__k);} _LIBCPP_INLINE_VISIBILITY pair<const_iterator,const_iterator> equal_range(const key_type& __k) const {return __tree_.__equal_range_unique(__k);} +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type + equal_range(const _K2& __k) {return __tree_.__equal_range_unique(__k);} + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type + equal_range(const _K2& __k) const {return __tree_.__equal_range_unique(__k);} +#endif private: typedef typename __base::__node __node; @@ -1152,7 +1316,7 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(key_type&& __k) __h.get_deleter().__first_constructed = true; __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); __h.get_deleter().__second_constructed = true; - return _VSTD::move(__h); + return __h; } #ifndef _LIBCPP_HAS_NO_VARIADICS @@ -1186,7 +1350,7 @@ map<_Key, _Tp, _Compare, _Allocator>::__construct_node_with_key(const key_type& __h.get_deleter().__first_constructed = true; __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); __h.get_deleter().__second_constructed = true; - return _VSTD::move(__h); + return _VSTD::move(__h); // explicitly moved for C++03 } template <class _Key, class _Tp, class _Compare, class _Allocator> @@ -1346,7 +1510,7 @@ swap(map<_Key, _Tp, _Compare, _Allocator>& __x, template <class _Key, class _Tp, class _Compare = less<_Key>, class _Allocator = allocator<pair<const _Key, _Tp> > > -class _LIBCPP_TYPE_VIS multimap +class _LIBCPP_TYPE_VIS_ONLY multimap { public: // types: @@ -1359,7 +1523,7 @@ public: typedef value_type& reference; typedef const value_type& const_reference; - class _LIBCPP_TYPE_VIS value_compare + class _LIBCPP_TYPE_VIS_ONLY value_compare : public binary_function<value_type, value_type, bool> { friend class multimap; @@ -1375,49 +1539,8 @@ public: }; private: -#if __cplusplus >= 201103L - union __value_type - { - typedef typename multimap::value_type value_type; - typedef typename multimap::__nc_value_type __nc_value_type; - value_type __cc; - __nc_value_type __nc; - - template <class ..._Args> - __value_type(_Args&& ...__args) - : __cc(std::forward<_Args>(__args)...) {} - __value_type(const __value_type& __v) - : __cc(std::move(__v.__cc)) {} - - __value_type(__value_type&& __v) - : __nc(std::move(__v.__nc)) {} - - __value_type& operator=(const __value_type& __v) - {__nc = __v.__cc; return *this;} - - __value_type& operator=(__value_type&& __v) - {__nc = std::move(__v.__nc); return *this;} - - ~__value_type() {__cc.~value_type();} - }; -#else - struct __value_type - { - typedef typename multimap::value_type value_type; - value_type __cc; - - __value_type() {} - - template <class _A0> - __value_type(const _A0& __a0) - : __cc(__a0) {} - - template <class _A0, class _A1> - __value_type(const _A0& __a0, const _A1& __a1) - : __cc(__a0, __a1) {} - }; -#endif + typedef _VSTD::__value_type<key_type, mapped_type> __value_type; typedef __map_value_compare<key_type, __value_type, key_compare> __vc; typedef typename allocator_traits<allocator_type>::template #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES @@ -1472,6 +1595,13 @@ public: insert(__f, __l); } +#if _LIBCPP_STD_VER > 11 + template <class _InputIterator> + _LIBCPP_INLINE_VISIBILITY + multimap(_InputIterator __f, _InputIterator __l, const allocator_type& __a) + : multimap(__f, __l, key_compare(), __a) {} +#endif + _LIBCPP_INLINE_VISIBILITY multimap(const multimap& __m) : __tree_(__m.__tree_.value_comp(), @@ -1531,6 +1661,12 @@ public: insert(__il.begin(), __il.end()); } +#if _LIBCPP_STD_VER > 11 + _LIBCPP_INLINE_VISIBILITY + multimap(initializer_list<value_type> __il, const allocator_type& __a) + : multimap(__il, key_compare(), __a) {} +#endif + _LIBCPP_INLINE_VISIBILITY multimap& operator=(initializer_list<value_type> __il) { @@ -1666,6 +1802,17 @@ public: iterator find(const key_type& __k) {return __tree_.find(__k);} _LIBCPP_INLINE_VISIBILITY const_iterator find(const key_type& __k) const {return __tree_.find(__k);} +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + find(const _K2& __k) {return __tree_.find(__k);} + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + find(const _K2& __k) const {return __tree_.find(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY size_type count(const key_type& __k) const {return __tree_.__count_multi(__k);} @@ -1675,18 +1822,51 @@ public: _LIBCPP_INLINE_VISIBILITY const_iterator lower_bound(const key_type& __k) const {return __tree_.lower_bound(__k);} +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} + + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY iterator upper_bound(const key_type& __k) {return __tree_.upper_bound(__k);} _LIBCPP_INLINE_VISIBILITY const_iterator upper_bound(const key_type& __k) const {return __tree_.upper_bound(__k);} +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY pair<iterator,iterator> equal_range(const key_type& __k) {return __tree_.__equal_range_multi(__k);} _LIBCPP_INLINE_VISIBILITY pair<const_iterator,const_iterator> equal_range(const key_type& __k) const {return __tree_.__equal_range_multi(__k);} +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type + equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type + equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} +#endif private: typedef typename __base::__node __node; diff --git a/system/include/libcxx/memory b/system/include/libcxx/memory index ffd0cd0c..bf44837f 100644 --- a/system/include/libcxx/memory +++ b/system/include/libcxx/memory @@ -90,7 +90,7 @@ struct allocator_traits template <class T> static void destroy(allocator_type& a, T* p); - static size_type max_size(const allocator_type& a); + static size_type max_size(const allocator_type& a); // noexcept in C++14 static allocator_type select_on_container_copy_construction(const allocator_type& a); @@ -496,8 +496,8 @@ public: long use_count() const noexcept; bool expired() const noexcept; shared_ptr<T> lock() const noexcept; - template<class U> bool owner_before(shared_ptr<U> const& b); - template<class U> bool owner_before(weak_ptr<U> const& b); + template<class U> bool owner_before(shared_ptr<U> const& b) const; + template<class U> bool owner_before(weak_ptr<U> const& b) const; }; // weak_ptr specialized algorithms: @@ -618,60 +618,12 @@ void* align(size_t alignment, size_t size, void*& ptr, size_t& space); _LIBCPP_BEGIN_NAMESPACE_STD -// addressof - -template <class _Tp> -inline _LIBCPP_INLINE_VISIBILITY -_Tp* -addressof(_Tp& __x) _NOEXCEPT -{ - return (_Tp*)&reinterpret_cast<const volatile char&>(__x); -} - -#if defined(_LIBCPP_HAS_OBJC_ARC) && !defined(_LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF) -// Objective-C++ Automatic Reference Counting uses qualified pointers -// that require special addressof() signatures. When -// _LIBCPP_PREDEFINED_OBJC_ARC_ADDRESSOF is defined, the compiler -// itself is providing these definitions. Otherwise, we provide them. -template <class _Tp> -inline _LIBCPP_INLINE_VISIBILITY -__strong _Tp* -addressof(__strong _Tp& __x) _NOEXCEPT -{ - return &__x; -} - -#ifdef _LIBCPP_HAS_OBJC_ARC_WEAK -template <class _Tp> -inline _LIBCPP_INLINE_VISIBILITY -__weak _Tp* -addressof(__weak _Tp& __x) _NOEXCEPT -{ - return &__x; -} -#endif - -template <class _Tp> -inline _LIBCPP_INLINE_VISIBILITY -__autoreleasing _Tp* -addressof(__autoreleasing _Tp& __x) _NOEXCEPT -{ - return &__x; -} - -template <class _Tp> -inline _LIBCPP_INLINE_VISIBILITY -__unsafe_unretained _Tp* -addressof(__unsafe_unretained _Tp& __x) _NOEXCEPT -{ - return &__x; -} -#endif +// addressof moved to <__functional_base> template <class _Tp> class allocator; template <> -class _LIBCPP_TYPE_VIS allocator<void> +class _LIBCPP_TYPE_VIS_ONLY allocator<void> { public: typedef void* pointer; @@ -682,7 +634,7 @@ public: }; template <> -class _LIBCPP_TYPE_VIS allocator<const void> +class _LIBCPP_TYPE_VIS_ONLY allocator<const void> { public: typedef const void* pointer; @@ -917,7 +869,7 @@ struct __pointer_traits_rebind<_Sp<_Tp, _A0, _A1, _A2>, _Up, false> #endif // _LIBCPP_HAS_NO_VARIADICS template <class _Ptr> -struct _LIBCPP_TYPE_VIS pointer_traits +struct _LIBCPP_TYPE_VIS_ONLY pointer_traits { typedef _Ptr pointer; typedef typename __pointer_traits_element_type<pointer>::type element_type; @@ -940,7 +892,7 @@ public: }; template <class _Tp> -struct _LIBCPP_TYPE_VIS pointer_traits<_Tp*> +struct _LIBCPP_TYPE_VIS_ONLY pointer_traits<_Tp*> { typedef _Tp* pointer; typedef _Tp element_type; @@ -965,13 +917,13 @@ public: namespace __has_pointer_type_imp { - template <class _Up> static __two test(...); - template <class _Up> static char test(typename _Up::pointer* = 0); + template <class _Up> static __two __test(...); + template <class _Up> static char __test(typename _Up::pointer* = 0); } template <class _Tp> struct __has_pointer_type - : public integral_constant<bool, sizeof(__has_pointer_type_imp::test<_Tp>(0)) == 1> + : public integral_constant<bool, sizeof(__has_pointer_type_imp::__test<_Tp>(0)) == 1> { }; @@ -1447,7 +1399,7 @@ struct __alloc_traits_difference_type<_Alloc, _Ptr, true> }; template <class _Alloc> -struct _LIBCPP_TYPE_VIS allocator_traits +struct _LIBCPP_TYPE_VIS_ONLY allocator_traits { typedef _Alloc allocator_type; typedef typename allocator_type::value_type value_type; @@ -1531,7 +1483,7 @@ struct _LIBCPP_TYPE_VIS allocator_traits {__destroy(__has_destroy<allocator_type, _Tp*>(), __a, __p);} _LIBCPP_INLINE_VISIBILITY - static size_type max_size(const allocator_type& __a) + static size_type max_size(const allocator_type& __a) _NOEXCEPT {return __max_size(__has_max_size<const allocator_type>(), __a);} _LIBCPP_INLINE_VISIBILITY @@ -1653,7 +1605,7 @@ private: // allocator template <class _Tp> -class _LIBCPP_TYPE_VIS allocator +class _LIBCPP_TYPE_VIS_ONLY allocator { public: typedef size_t size_type; @@ -1745,7 +1697,7 @@ public: }; template <class _Tp> -class _LIBCPP_TYPE_VIS allocator<const _Tp> +class _LIBCPP_TYPE_VIS_ONLY allocator<const _Tp> { public: typedef size_t size_type; @@ -1843,7 +1795,7 @@ inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const allocator<_Tp>&, const allocator<_Up>&) _NOEXCEPT {return false;} template <class _OutputIterator, class _Tp> -class _LIBCPP_TYPE_VIS raw_storage_iterator +class _LIBCPP_TYPE_VIS_ONLY raw_storage_iterator : public iterator<output_iterator_tag, _Tp, // purposefully not C++03 ptrdiff_t, // purposefully not C++03 @@ -1896,7 +1848,7 @@ struct auto_ptr_ref }; template<class _Tp> -class _LIBCPP_TYPE_VIS auto_ptr +class _LIBCPP_TYPE_VIS_ONLY auto_ptr { private: _Tp* __ptr_; @@ -1940,7 +1892,7 @@ public: }; template <> -class _LIBCPP_TYPE_VIS auto_ptr<void> +class _LIBCPP_TYPE_VIS_ONLY auto_ptr<void> { public: typedef void element_type; @@ -2476,7 +2428,7 @@ struct __same_or_less_cv_qualified<_Ptr1, _Ptr2, true> // default_delete template <class _Tp> -struct _LIBCPP_TYPE_VIS default_delete +struct _LIBCPP_TYPE_VIS_ONLY default_delete { #ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR default_delete() _NOEXCEPT = default; @@ -2495,7 +2447,7 @@ struct _LIBCPP_TYPE_VIS default_delete }; template <class _Tp> -struct _LIBCPP_TYPE_VIS default_delete<_Tp[]> +struct _LIBCPP_TYPE_VIS_ONLY default_delete<_Tp[]> { public: #ifndef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS @@ -2518,7 +2470,7 @@ public: }; template <class _Tp, class _Dp = default_delete<_Tp> > -class _LIBCPP_TYPE_VIS unique_ptr +class _LIBCPP_TYPE_VIS_ONLY unique_ptr { public: typedef _Tp element_type; @@ -2697,7 +2649,7 @@ public: }; template <class _Tp, class _Dp> -class _LIBCPP_TYPE_VIS unique_ptr<_Tp[], _Dp> +class _LIBCPP_TYPE_VIS_ONLY unique_ptr<_Tp[], _Dp> { public: typedef _Tp element_type; @@ -3452,7 +3404,7 @@ struct __scalar_hash<_Tp, 4> }; template<class _Tp> -struct _LIBCPP_TYPE_VIS hash<_Tp*> +struct _LIBCPP_TYPE_VIS_ONLY hash<_Tp*> : public unary_function<_Tp*, size_t> { _LIBCPP_INLINE_VISIBILITY @@ -3469,7 +3421,7 @@ struct _LIBCPP_TYPE_VIS hash<_Tp*> }; template <class _Tp, class _Dp> -struct _LIBCPP_TYPE_VIS hash<unique_ptr<_Tp, _Dp> > +struct _LIBCPP_TYPE_VIS_ONLY hash<unique_ptr<_Tp, _Dp> > { typedef unique_ptr<_Tp, _Dp> argument_type; typedef size_t result_type; @@ -3642,9 +3594,9 @@ public: virtual const char* what() const _NOEXCEPT; }; -template<class _Tp> class _LIBCPP_TYPE_VIS weak_ptr; +template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY weak_ptr; -class __shared_count +class _LIBCPP_TYPE_VIS __shared_count { __shared_count(const __shared_count&); __shared_count& operator=(const __shared_count&); @@ -3666,7 +3618,7 @@ public: long use_count() const _NOEXCEPT {return __shared_owners_ + 1;} }; -class __shared_weak_count +class _LIBCPP_TYPE_VIS __shared_weak_count : private __shared_count { long __shared_weak_owners_; @@ -3811,10 +3763,10 @@ __shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT __a.deallocate(this, 1); } -template<class _Tp> class _LIBCPP_TYPE_VIS enable_shared_from_this; +template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY enable_shared_from_this; template<class _Tp> -class _LIBCPP_TYPE_VIS shared_ptr +class _LIBCPP_TYPE_VIS_ONLY shared_ptr { public: typedef _Tp element_type; @@ -3943,8 +3895,8 @@ public: < !is_array<_Yp>::value && is_convertible<_Yp*, element_type*>::value, - shared_ptr& - >::type + shared_ptr + >::type& operator=(auto_ptr<_Yp>&& __r); #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES template<class _Yp> @@ -4083,8 +4035,8 @@ private: _LIBCPP_INLINE_VISIBILITY void __enable_weak_this(const void*) _NOEXCEPT {} - template <class _Up> friend class _LIBCPP_TYPE_VIS shared_ptr; - template <class _Up> friend class _LIBCPP_TYPE_VIS weak_ptr; + template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY shared_ptr; + template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY weak_ptr; }; template<class _Tp> @@ -4570,8 +4522,8 @@ typename enable_if < !is_array<_Yp>::value && is_convertible<_Yp*, _Tp*>::value, - shared_ptr<_Tp>& ->::type + shared_ptr<_Tp> +>::type& shared_ptr<_Tp>::operator=(auto_ptr<_Yp>&& __r) { shared_ptr(_VSTD::move(__r)).swap(*this); @@ -4980,7 +4932,7 @@ get_deleter(const shared_ptr<_Tp>& __p) _NOEXCEPT #endif // _LIBCPP_NO_RTTI template<class _Tp> -class _LIBCPP_TYPE_VIS weak_ptr +class _LIBCPP_TYPE_VIS_ONLY weak_ptr { public: typedef _Tp element_type; @@ -5055,8 +5007,8 @@ public: bool owner_before(const weak_ptr<_Up>& __r) const {return __cntrl_ < __r.__cntrl_;} - template <class _Up> friend class _LIBCPP_TYPE_VIS weak_ptr; - template <class _Up> friend class _LIBCPP_TYPE_VIS shared_ptr; + template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY weak_ptr; + template <class _Up> friend class _LIBCPP_TYPE_VIS_ONLY shared_ptr; }; template<class _Tp> @@ -5256,7 +5208,7 @@ weak_ptr<_Tp>::lock() const _NOEXCEPT template <class _Tp> struct owner_less; template <class _Tp> -struct _LIBCPP_TYPE_VIS owner_less<shared_ptr<_Tp> > +struct _LIBCPP_TYPE_VIS_ONLY owner_less<shared_ptr<_Tp> > : binary_function<shared_ptr<_Tp>, shared_ptr<_Tp>, bool> { typedef bool result_type; @@ -5272,7 +5224,7 @@ struct _LIBCPP_TYPE_VIS owner_less<shared_ptr<_Tp> > }; template <class _Tp> -struct _LIBCPP_TYPE_VIS owner_less<weak_ptr<_Tp> > +struct _LIBCPP_TYPE_VIS_ONLY owner_less<weak_ptr<_Tp> > : binary_function<weak_ptr<_Tp>, weak_ptr<_Tp>, bool> { typedef bool result_type; @@ -5288,7 +5240,7 @@ struct _LIBCPP_TYPE_VIS owner_less<weak_ptr<_Tp> > }; template<class _Tp> -class _LIBCPP_TYPE_VIS enable_shared_from_this +class _LIBCPP_TYPE_VIS_ONLY enable_shared_from_this { mutable weak_ptr<_Tp> __weak_this_; protected: @@ -5313,7 +5265,7 @@ public: }; template <class _Tp> -struct _LIBCPP_TYPE_VIS hash<shared_ptr<_Tp> > +struct _LIBCPP_TYPE_VIS_ONLY hash<shared_ptr<_Tp> > { typedef shared_ptr<_Tp> argument_type; typedef size_t result_type; @@ -5331,7 +5283,7 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p); #if __has_feature(cxx_atomic) -class __sp_mut +class _LIBCPP_TYPE_VIS __sp_mut { void* __lx; public: @@ -5475,11 +5427,11 @@ struct _LIBCPP_TYPE_VIS pointer_safety operator int() const {return __v_;} }; -void declare_reachable(void* __p); -void declare_no_pointers(char* __p, size_t __n); -void undeclare_no_pointers(char* __p, size_t __n); -pointer_safety get_pointer_safety() _NOEXCEPT; -void* __undeclare_reachable(void* __p); +_LIBCPP_FUNC_VIS void declare_reachable(void* __p); +_LIBCPP_FUNC_VIS void declare_no_pointers(char* __p, size_t __n); +_LIBCPP_FUNC_VIS void undeclare_no_pointers(char* __p, size_t __n); +_LIBCPP_FUNC_VIS pointer_safety get_pointer_safety() _NOEXCEPT; +_LIBCPP_FUNC_VIS void* __undeclare_reachable(void* __p); template <class _Tp> inline _LIBCPP_INLINE_VISIBILITY @@ -5489,7 +5441,7 @@ undeclare_reachable(_Tp* __p) return static_cast<_Tp*>(__undeclare_reachable(__p)); } -void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space); +_LIBCPP_FUNC_VIS void* align(size_t __align, size_t __sz, void*& __ptr, size_t& __space); _LIBCPP_END_NAMESPACE_STD diff --git a/system/include/libcxx/mutex b/system/include/libcxx/mutex index e2b5d6bf..e0c02adb 100644 --- a/system/include/libcxx/mutex +++ b/system/include/libcxx/mutex @@ -441,7 +441,7 @@ void call_once(once_flag&, _Callable); #endif // _LIBCPP_HAS_NO_VARIADICS -struct _LIBCPP_TYPE_VIS once_flag +struct _LIBCPP_TYPE_VIS_ONLY once_flag { _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR @@ -527,7 +527,7 @@ __call_once_proxy(void* __vp) (*__p)(); } -void __call_once(volatile unsigned long&, void*, void(*)(void*)); +_LIBCPP_FUNC_VIS void __call_once(volatile unsigned long&, void*, void(*)(void*)); #ifndef _LIBCPP_HAS_NO_VARIADICS diff --git a/system/include/libcxx/new b/system/include/libcxx/new index 1e85798b..31bb5982 100644 --- a/system/include/libcxx/new +++ b/system/include/libcxx/new @@ -27,6 +27,18 @@ public: virtual const char* what() const noexcept; }; +class bad_array_length : public bad_alloc // C++14 +{ +public: + bad_array_length() noexcept; +}; + +class bad_array_new_length : public bad_alloc +{ +public: + bad_array_new_length() noexcept; +}; + struct nothrow_t {}; extern const nothrow_t nothrow; typedef void (*new_handler)(); @@ -81,7 +93,18 @@ public: virtual const char* what() const _NOEXCEPT; }; -void __throw_bad_alloc(); // not in C++ spec +#if defined(_LIBCPP_BUILDING_NEW) || (_LIBCPP_STD_VER > 11) +class _LIBCPP_EXCEPTION_ABI bad_array_length + : public bad_alloc +{ +public: + bad_array_length() _NOEXCEPT; + virtual ~bad_array_length() _NOEXCEPT; + virtual const char* what() const _NOEXCEPT; +}; +#endif + +_LIBCPP_FUNC_VIS void __throw_bad_alloc(); // not in C++ spec struct _LIBCPP_TYPE_VIS nothrow_t {}; extern _LIBCPP_FUNC_VIS const nothrow_t nothrow; @@ -91,27 +114,33 @@ _LIBCPP_FUNC_VIS new_handler get_new_handler() _NOEXCEPT; } // std -_LIBCPP_FUNC_VIS void* operator new(std::size_t __sz) +#if defined(_WIN32) && !defined(cxx_EXPORTS) +# define _LIBCPP_NEW_DELETE_VIS _LIBCPP_FUNC_VIS_ONLY +#else +# define _LIBCPP_NEW_DELETE_VIS _LIBCPP_FUNC_VIS +#endif + +_LIBCPP_NEW_DELETE_VIS void* operator new(std::size_t __sz) #if !__has_feature(cxx_noexcept) throw(std::bad_alloc) #endif ; -_LIBCPP_FUNC_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS; -_LIBCPP_FUNC_VIS void operator delete(void* __p) _NOEXCEPT; -_LIBCPP_FUNC_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT; +_LIBCPP_NEW_DELETE_VIS void* operator new(std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS; +_LIBCPP_NEW_DELETE_VIS void operator delete(void* __p) _NOEXCEPT; +_LIBCPP_NEW_DELETE_VIS void operator delete(void* __p, const std::nothrow_t&) _NOEXCEPT; -_LIBCPP_FUNC_VIS void* operator new[](std::size_t __sz) +_LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz) #if !__has_feature(cxx_noexcept) throw(std::bad_alloc) #endif ; -_LIBCPP_FUNC_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS; -_LIBCPP_FUNC_VIS void operator delete[](void* __p) _NOEXCEPT; -_LIBCPP_FUNC_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT; - -_LIBCPP_INLINE_VISIBILITY inline void* operator new (std::size_t, void* __p) _NOEXCEPT {return __p;} -_LIBCPP_INLINE_VISIBILITY inline void* operator new[](std::size_t, void* __p) _NOEXCEPT {return __p;} -_LIBCPP_INLINE_VISIBILITY inline void operator delete (void*, void*) _NOEXCEPT {} -_LIBCPP_INLINE_VISIBILITY inline void operator delete[](void*, void*) _NOEXCEPT {} +_LIBCPP_NEW_DELETE_VIS void* operator new[](std::size_t __sz, const std::nothrow_t&) _NOEXCEPT _NOALIAS; +_LIBCPP_NEW_DELETE_VIS void operator delete[](void* __p) _NOEXCEPT; +_LIBCPP_NEW_DELETE_VIS void operator delete[](void* __p, const std::nothrow_t&) _NOEXCEPT; + +inline _LIBCPP_INLINE_VISIBILITY void* operator new (std::size_t, void* __p) _NOEXCEPT {return __p;} +inline _LIBCPP_INLINE_VISIBILITY void* operator new[](std::size_t, void* __p) _NOEXCEPT {return __p;} +inline _LIBCPP_INLINE_VISIBILITY void operator delete (void*, void*) _NOEXCEPT {} +inline _LIBCPP_INLINE_VISIBILITY void operator delete[](void*, void*) _NOEXCEPT {} #endif // _LIBCPP_NEW diff --git a/system/include/libcxx/numeric b/system/include/libcxx/numeric index c201a5f5..e520c8e0 100644 --- a/system/include/libcxx/numeric +++ b/system/include/libcxx/numeric @@ -157,7 +157,7 @@ adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterat { typename iterator_traits<_InputIterator>::value_type __t2(*__first); *__result = __t2 - __t1; - __t1 = __t2; + __t1 = _VSTD::move(__t2); } } return __result; @@ -177,7 +177,7 @@ adjacent_difference(_InputIterator __first, _InputIterator __last, _OutputIterat { typename iterator_traits<_InputIterator>::value_type __t2(*__first); *__result = __binary_op(__t2, __t1); - __t1 = __t2; + __t1 = _VSTD::move(__t2); } } return __result; diff --git a/system/include/libcxx/optional b/system/include/libcxx/optional new file mode 100644 index 00000000..a8e6a991 --- /dev/null +++ b/system/include/libcxx/optional @@ -0,0 +1,697 @@ +// -*- C++ -*- +//===-------------------------- optional ----------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_OPTIONAL +#define _LIBCPP_OPTIONAL + +/* + optional synopsis + +// C++1y + +#include <initializer_list> + +namespace std +{ + +// optional for object types +template <class T> +class optional +{ +public: + typedef T value_type; + + // constructors + constexpr optional() noexcept; + constexpr optional(nullopt_t) noexcept; + optional(const optional&); + optional(optional&&) noexcept(is_nothrow_move_constructible<T>::value); + constexpr optional(const T&); + constexpr optional(T&&); + template <class... Args> constexpr explicit optional(in_place_t, Args&&...); + template <class U, class... Args> + constexpr explicit optional(in_place_t, initializer_list<U>, Args&&...); + + // destructor + ~optional(); + + // assignment + optional& operator=(nullopt_t) noexcept; + optional& operator=(const optional&); + optional& operator=(optional&&) + noexcept(is_nothrow_move_assignable<T>::value && + is_nothrow_move_constructible<T>::value); + template <class U> optional& operator=(U&&); + template <class... Args> void emplace(Args&&...); + template <class U, class... Args> void emplace(initializer_list<U>, Args&&...); + + // swap + void swap(optional&) + noexcept(is_nothrow_move_constructible<T>::value && + noexcept(swap(declval<T&>(), declval<T&>()))); + + // observers + constexpr T const* operator->() const; + T* operator->(); + constexpr T const& operator*() const; + T& operator*(); + constexpr explicit operator bool() const noexcept; + constexpr T const& value() const; + T& value(); + template <class U> constexpr T value_or(U&&) const&; + template <class U> T value_or(U&&) &&; +}; + +// In-place construction +struct in_place_t{}; +constexpr in_place_t in_place{}; + +// Disengaged state indicator +struct nullopt_t{see below}; +constexpr nullopt_t nullopt(unspecified); + +// class bad_optional_access +class bad_optional_access + : public logic_error +{ +public: + explicit bad_optional_access(const string& what_arg); + explicit bad_optional_access(const char* what_arg); +}; + +// Relational operators +template <class T> constexpr bool operator==(const optional<T>&, const optional<T>&); +template <class T> constexpr bool operator< (const optional<T>&, const optional<T>&); + +// Comparison with nullopt +template <class T> constexpr bool operator==(const optional<T>&, nullopt_t) noexcept; +template <class T> constexpr bool operator==(nullopt_t, const optional<T>&) noexcept; +template <class T> constexpr bool operator<(const optional<T>&, nullopt_t) noexcept; +template <class T> constexpr bool operator<(nullopt_t, const optional<T>&) noexcept; + +// Comparison with T +template <class T> constexpr bool operator==(const optional<T>&, const T&); +template <class T> constexpr bool operator==(const T&, const optional<T>&); +template <class T> constexpr bool operator<(const optional<T>&, const T&); +template <class T> constexpr bool operator<(const T&, const optional<T>&); + +// Specialized algorithms +template <class T> void swap(optional<T>&, optional<T>&) noexcept(see below); +template <class T> constexpr optional<typename decay<T>::type> make_optional(T&&); + +// hash support +template <class T> struct hash; +template <class T> struct hash<optional<T>>; + +} // std + +*/ + +#include <__config> +#include <functional> +#include <stdexcept> + +namespace std // purposefully not using versioning namespace +{ + +class _LIBCPP_EXCEPTION_ABI bad_optional_access + : public logic_error +{ +public: +#if _LIBCPP_STD_VER > 11 + _LIBCPP_INLINE_VISIBILITY explicit bad_optional_access(const string& __arg) + : logic_error(__arg) {} + _LIBCPP_INLINE_VISIBILITY explicit bad_optional_access(const char* __arg) + : logic_error(__arg) {} + _LIBCPP_INLINE_VISIBILITY bad_optional_access(const bad_optional_access&) noexcept = default; + _LIBCPP_INLINE_VISIBILITY bad_optional_access& operator=(const bad_optional_access&) noexcept = default; +#else +private: + bad_optional_access(const bad_optional_access&); + bad_optional_access& operator=(const bad_optional_access&); +public: +#endif // _LIBCPP_STD_VER > 11 + // Get the key function ~bad_optional_access() into the dylib even if not compiling for C++1y + virtual ~bad_optional_access() _NOEXCEPT; +}; + +} // std + +#if _LIBCPP_STD_VER > 11 + +#include <initializer_list> +#include <type_traits> +#include <new> +#include <__functional_base> + +#include <__undef_min_max> + +#ifdef _LIBCPP_DEBUG +# include <__debug> +#else +# define _LIBCPP_ASSERT(x, m) ((void)0) +#endif + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +struct in_place_t {}; +constexpr in_place_t in_place{}; + +struct nullopt_t +{ + explicit constexpr nullopt_t(int) noexcept {} +}; + +constexpr nullopt_t nullopt{0}; + +template <class _Tp, bool = is_trivially_destructible<_Tp>::value> +class __optional_storage +{ +protected: + typedef _Tp value_type; + union + { + char __null_state_; + value_type __val_; + }; + bool __engaged_ = false; + + _LIBCPP_INLINE_VISIBILITY + ~__optional_storage() + { + if (__engaged_) + __val_.~value_type(); + } + + _LIBCPP_INLINE_VISIBILITY + constexpr __optional_storage() noexcept + : __null_state_('\0') {} + + _LIBCPP_INLINE_VISIBILITY + __optional_storage(const __optional_storage& __x) + : __engaged_(__x.__engaged_) + { + if (__engaged_) + ::new(_VSTD::addressof(__val_)) value_type(__x.__val_); + } + + _LIBCPP_INLINE_VISIBILITY + __optional_storage(__optional_storage&& __x) + noexcept(is_nothrow_move_constructible<value_type>::value) + : __engaged_(__x.__engaged_) + { + if (__engaged_) + ::new(_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_)); + } + + _LIBCPP_INLINE_VISIBILITY + constexpr __optional_storage(const value_type& __v) + : __val_(__v), + __engaged_(true) {} + + _LIBCPP_INLINE_VISIBILITY + constexpr __optional_storage(value_type&& __v) + : __val_(_VSTD::move(__v)), + __engaged_(true) {} + + template <class... _Args> + _LIBCPP_INLINE_VISIBILITY + constexpr + explicit __optional_storage(in_place_t, _Args&&... __args) + : __val_(_VSTD::forward<_Args>(__args)...), + __engaged_(true) {} +}; + +template <class _Tp> +class __optional_storage<_Tp, true> +{ +protected: + typedef _Tp value_type; + union + { + char __null_state_; + value_type __val_; + }; + bool __engaged_ = false; + + _LIBCPP_INLINE_VISIBILITY + constexpr __optional_storage() noexcept + : __null_state_('\0') {} + + _LIBCPP_INLINE_VISIBILITY + __optional_storage(const __optional_storage& __x) + : __engaged_(__x.__engaged_) + { + if (__engaged_) + ::new(_VSTD::addressof(__val_)) value_type(__x.__val_); + } + + _LIBCPP_INLINE_VISIBILITY + __optional_storage(__optional_storage&& __x) + noexcept(is_nothrow_move_constructible<value_type>::value) + : __engaged_(__x.__engaged_) + { + if (__engaged_) + ::new(_VSTD::addressof(__val_)) value_type(_VSTD::move(__x.__val_)); + } + + _LIBCPP_INLINE_VISIBILITY + constexpr __optional_storage(const value_type& __v) + : __val_(__v), + __engaged_(true) {} + + _LIBCPP_INLINE_VISIBILITY + constexpr __optional_storage(value_type&& __v) + : __val_(_VSTD::move(__v)), + __engaged_(true) {} + + template <class... _Args> + _LIBCPP_INLINE_VISIBILITY + constexpr + explicit __optional_storage(in_place_t, _Args&&... __args) + : __val_(_VSTD::forward<_Args>(__args)...), + __engaged_(true) {} +}; + +template <class _Tp> +class optional + : private __optional_storage<_Tp> +{ + typedef __optional_storage<_Tp> __base; +public: + typedef _Tp value_type; + + static_assert(!is_reference<value_type>::value, + "Instantiation of optional with a reference type is ill-formed."); + static_assert(!is_same<typename remove_cv<value_type>::type, in_place_t>::value, + "Instantiation of optional with a in_place_t type is ill-formed."); + static_assert(!is_same<typename remove_cv<value_type>::type, nullopt_t>::value, + "Instantiation of optional with a nullopt_t type is ill-formed."); + static_assert(is_object<value_type>::value, + "Instantiation of optional with a non-object type is undefined behavior."); + static_assert(is_nothrow_destructible<value_type>::value, + "Instantiation of optional with an object type that is not noexcept destructible is undefined behavior."); + + _LIBCPP_INLINE_VISIBILITY constexpr optional() noexcept {} + _LIBCPP_INLINE_VISIBILITY optional(const optional&) = default; + _LIBCPP_INLINE_VISIBILITY optional(optional&&) = default; + _LIBCPP_INLINE_VISIBILITY ~optional() = default; + _LIBCPP_INLINE_VISIBILITY constexpr optional(nullopt_t) noexcept {} + _LIBCPP_INLINE_VISIBILITY constexpr optional(const value_type& __v) + : __base(__v) {} + _LIBCPP_INLINE_VISIBILITY constexpr optional(value_type&& __v) + : __base(_VSTD::move(__v)) {} + + template <class... _Args, + class = typename enable_if + < + is_constructible<value_type, _Args...>::value + >::type + > + _LIBCPP_INLINE_VISIBILITY + constexpr + explicit optional(in_place_t, _Args&&... __args) + : __base(in_place, _VSTD::forward<_Args>(__args)...) {} + + template <class _Up, class... _Args, + class = typename enable_if + < + is_constructible<value_type, initializer_list<_Up>&, _Args...>::value + >::type + > + _LIBCPP_INLINE_VISIBILITY + constexpr + explicit optional(in_place_t, initializer_list<_Up> __il, _Args&&... __args) + : __base(in_place, __il, _VSTD::forward<_Args>(__args)...) {} + + _LIBCPP_INLINE_VISIBILITY + optional& operator=(nullopt_t) noexcept + { + if (this->__engaged_) + { + this->__val_.~value_type(); + this->__engaged_ = false; + } + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + optional& + operator=(const optional& __opt) + { + if (this->__engaged_ == __opt.__engaged_) + { + if (this->__engaged_) + this->__val_ = __opt.__val_; + } + else + { + if (this->__engaged_) + this->__val_.~value_type(); + else + ::new(_VSTD::addressof(this->__val_)) value_type(__opt.__val_); + this->__engaged_ = __opt.__engaged_; + } + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + optional& + operator=(optional&& __opt) + noexcept(is_nothrow_move_assignable<value_type>::value && + is_nothrow_move_constructible<value_type>::value) + { + if (this->__engaged_ == __opt.__engaged_) + { + if (this->__engaged_) + this->__val_ = _VSTD::move(__opt.__val_); + } + else + { + if (this->__engaged_) + this->__val_.~value_type(); + else + ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::move(__opt.__val_)); + this->__engaged_ = __opt.__engaged_; + } + return *this; + } + + template <class _Up, + class = typename enable_if + < + is_same<typename remove_reference<_Up>::type, value_type>::value && + is_constructible<value_type, _Up>::value && + is_assignable<value_type&, _Up>::value + >::type + > + _LIBCPP_INLINE_VISIBILITY + optional& + operator=(_Up&& __v) + { + if (this->__engaged_) + this->__val_ = _VSTD::forward<_Up>(__v); + else + { + ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Up>(__v)); + this->__engaged_ = true; + } + return *this; + } + + template <class... _Args, + class = typename enable_if + < + is_constructible<value_type, _Args...>::value + >::type + > + _LIBCPP_INLINE_VISIBILITY + void + emplace(_Args&&... __args) + { + *this = nullopt; + ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::forward<_Args>(__args)...); + this->__engaged_ = true; + } + + template <class _Up, class... _Args, + class = typename enable_if + < + is_constructible<value_type, initializer_list<_Up>&, _Args...>::value + >::type + > + _LIBCPP_INLINE_VISIBILITY + void + emplace(initializer_list<_Up> __il, _Args&&... __args) + { + *this = nullopt; + ::new(_VSTD::addressof(this->__val_)) value_type(__il, _VSTD::forward<_Args>(__args)...); + this->__engaged_ = true; + } + + _LIBCPP_INLINE_VISIBILITY + void + swap(optional& __opt) + noexcept(is_nothrow_move_constructible<value_type>::value && + __is_nothrow_swappable<value_type>::value) + { + using _VSTD::swap; + if (this->__engaged_ == __opt.__engaged_) + { + if (this->__engaged_) + swap(this->__val_, __opt.__val_); + } + else + { + if (this->__engaged_) + { + ::new(_VSTD::addressof(__opt.__val_)) value_type(_VSTD::move(this->__val_)); + this->__val_.~value_type(); + } + else + { + ::new(_VSTD::addressof(this->__val_)) value_type(_VSTD::move(__opt.__val_)); + __opt.__val_.~value_type(); + } + swap(this->__engaged_, __opt.__engaged_); + } + } + + _LIBCPP_INLINE_VISIBILITY + constexpr + value_type const* + operator->() const + { + _LIBCPP_ASSERT(this->__engaged_, "optional operator-> called for disengaged value"); + return __operator_arrow(__has_operator_addressof<value_type>{}); + } + + _LIBCPP_INLINE_VISIBILITY + value_type* + operator->() + { + _LIBCPP_ASSERT(this->__engaged_, "optional operator-> called for disengaged value"); + return _VSTD::addressof(this->__val_); + } + + _LIBCPP_INLINE_VISIBILITY + constexpr + const value_type& + operator*() const + { + _LIBCPP_ASSERT(this->__engaged_, "optional operator* called for disengaged value"); + return this->__val_; + } + + _LIBCPP_INLINE_VISIBILITY + value_type& + operator*() + { + _LIBCPP_ASSERT(this->__engaged_, "optional operator* called for disengaged value"); + return this->__val_; + } + + _LIBCPP_INLINE_VISIBILITY + constexpr explicit operator bool() const noexcept {return this->__engaged_;} + + _LIBCPP_INLINE_VISIBILITY + constexpr value_type const& value() const + { + if (!this->__engaged_) + throw bad_optional_access("optional<T>::value: not engaged"); + return this->__val_; + } + + _LIBCPP_INLINE_VISIBILITY + value_type& value() + { + if (!this->__engaged_) + throw bad_optional_access("optional<T>::value: not engaged"); + return this->__val_; + } + + template <class _Up> + _LIBCPP_INLINE_VISIBILITY + constexpr value_type value_or(_Up&& __v) const& + { + static_assert(is_copy_constructible<value_type>::value, + "optional<T>::value_or: T must be copy constructible"); + static_assert(is_convertible<_Up, value_type>::value, + "optional<T>::value_or: U must be convertible to T"); + return this->__engaged_ ? this->__val_ : + static_cast<value_type>(_VSTD::forward<_Up>(__v)); + } + + template <class _Up> + _LIBCPP_INLINE_VISIBILITY + value_type value_or(_Up&& __v) && + { + static_assert(is_move_constructible<value_type>::value, + "optional<T>::value_or: T must be move constructible"); + static_assert(is_convertible<_Up, value_type>::value, + "optional<T>::value_or: U must be convertible to T"); + return this->__engaged_ ? _VSTD::move(this->__val_) : + static_cast<value_type>(_VSTD::forward<_Up>(__v)); + } + +private: + _LIBCPP_INLINE_VISIBILITY + value_type const* + __operator_arrow(true_type) const + { + return _VSTD::addressof(this->__val_); + } + + _LIBCPP_INLINE_VISIBILITY + constexpr + value_type const* + __operator_arrow(false_type) const + { + return &this->__val_; + } +}; + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator==(const optional<_Tp>& __x, const optional<_Tp>& __y) +{ + if (static_cast<bool>(__x) != static_cast<bool>(__y)) + return false; + if (!static_cast<bool>(__x)) + return true; + return *__x == *__y; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<(const optional<_Tp>& __x, const optional<_Tp>& __y) +{ + if (!static_cast<bool>(__y)) + return false; + if (!static_cast<bool>(__x)) + return true; + return less<_Tp>{}(*__x, *__y); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator==(const optional<_Tp>& __x, nullopt_t) noexcept +{ + return !static_cast<bool>(__x); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator==(nullopt_t, const optional<_Tp>& __x) noexcept +{ + return !static_cast<bool>(__x); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<(const optional<_Tp>&, nullopt_t) noexcept +{ + return false; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<(nullopt_t, const optional<_Tp>& __x) noexcept +{ + return static_cast<bool>(__x); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator==(const optional<_Tp>& __x, const _Tp& __v) +{ + return static_cast<bool>(__x) ? *__x == __v : false; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator==(const _Tp& __v, const optional<_Tp>& __x) +{ + return static_cast<bool>(__x) ? *__x == __v : false; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<(const optional<_Tp>& __x, const _Tp& __v) +{ + return static_cast<bool>(__x) ? less<_Tp>{}(*__x, __v) : true; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +bool +operator<(const _Tp& __v, const optional<_Tp>& __x) +{ + return static_cast<bool>(__x) ? less<_Tp>{}(__v, *__x) : false; +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +void +swap(optional<_Tp>& __x, optional<_Tp>& __y) noexcept(noexcept(__x.swap(__y))) +{ + __x.swap(__y); +} + +template <class _Tp> +inline _LIBCPP_INLINE_VISIBILITY +constexpr +optional<typename decay<_Tp>::type> +make_optional(_Tp&& __v) +{ + return optional<typename decay<_Tp>::type>(_VSTD::forward<_Tp>(__v)); +} + +template <class _Tp> +struct _LIBCPP_TYPE_VIS_ONLY hash<optional<_Tp> > +{ + typedef optional<_Tp> argument_type; + typedef size_t result_type; + + _LIBCPP_INLINE_VISIBILITY + result_type operator()(const argument_type& __opt) const _NOEXCEPT + { + return static_cast<bool>(__opt) ? hash<_Tp>()(*__opt) : 0; + } +}; + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP_STD_VER > 11 + +#endif // _LIBCPP_ARRAY diff --git a/system/include/libcxx/ostream b/system/include/libcxx/ostream index eac9c8f0..041314ac 100644 --- a/system/include/libcxx/ostream +++ b/system/include/libcxx/ostream @@ -32,6 +32,7 @@ public: virtual ~basic_ostream(); // 27.7.2.3 Assign/swap + basic_ostream& operator=(const basic_ostream& rhs) = delete; // C++14 basic_ostream& operator=(basic_ostream&& rhs); void swap(basic_ostream& rhs); @@ -140,7 +141,7 @@ template <class charT, class traits, class T> _LIBCPP_BEGIN_NAMESPACE_STD template <class _CharT, class _Traits> -class _LIBCPP_TYPE_VIS basic_ostream +class _LIBCPP_TYPE_VIS_ONLY basic_ostream : virtual public basic_ios<_CharT, _Traits> { public: @@ -161,6 +162,9 @@ protected: #endif // 27.7.2.3 Assign/swap +#if _LIBCPP_STD_VER > 11 + basic_ostream& operator=(const basic_ostream&) = delete; +#endif #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES _LIBCPP_INLINE_VISIBILITY basic_ostream& operator=(basic_ostream&& __rhs); @@ -169,7 +173,7 @@ protected: public: // 27.7.2.4 Prefix/suffix: - class _LIBCPP_TYPE_VIS sentry; + class _LIBCPP_TYPE_VIS_ONLY sentry; // 27.7.2.6 Formatted output: basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&)); @@ -207,7 +211,7 @@ protected: }; template <class _CharT, class _Traits> -class _LIBCPP_TYPE_VIS basic_ostream<_CharT, _Traits>::sentry +class _LIBCPP_TYPE_VIS_ONLY basic_ostream<_CharT, _Traits>::sentry { bool __ok_; basic_ostream<_CharT, _Traits>& __os_; @@ -1155,7 +1159,8 @@ inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::seekp(pos_type __pos) { - if (!this->fail()) + sentry __s(*this); + if (__s) { if (this->rdbuf()->pubseekpos(__pos, ios_base::out) == pos_type(-1)) this->setstate(ios_base::failbit); @@ -1168,8 +1173,12 @@ inline _LIBCPP_INLINE_VISIBILITY basic_ostream<_CharT, _Traits>& basic_ostream<_CharT, _Traits>::seekp(off_type __off, ios_base::seekdir __dir) { - if (!this->fail()) - this->rdbuf()->pubseekoff(__off, __dir, ios_base::out); + sentry __s(*this); + if (__s) + { + if (this->rdbuf()->pubseekoff(__off, __dir, ios_base::out) == pos_type(-1)) + this->setstate(ios_base::failbit); + } return *this; } @@ -1278,8 +1287,8 @@ operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x) use_facet<ctype<_CharT> >(__os.getloc()).widen('1')); } -_LIBCPP_EXTERN_TEMPLATE(class basic_ostream<char>) -_LIBCPP_EXTERN_TEMPLATE(class basic_ostream<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_ostream<char>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_ostream<wchar_t>) _LIBCPP_END_NAMESPACE_STD diff --git a/system/include/libcxx/queue b/system/include/libcxx/queue index 8d1a9dfc..bdfd7060 100644 --- a/system/include/libcxx/queue +++ b/system/include/libcxx/queue @@ -177,7 +177,7 @@ template <class T, class Container, class Compare> _LIBCPP_BEGIN_NAMESPACE_STD -template <class _Tp, class _Container> class _LIBCPP_TYPE_VIS queue; +template <class _Tp, class _Container> class _LIBCPP_TYPE_VIS_ONLY queue; template <class _Tp, class _Container> _LIBCPP_INLINE_VISIBILITY @@ -190,7 +190,7 @@ bool operator< (const queue<_Tp, _Container>& __x,const queue<_Tp, _Container>& __y); template <class _Tp, class _Container = deque<_Tp> > -class _LIBCPP_TYPE_VIS queue +class _LIBCPP_TYPE_VIS_ONLY queue { public: typedef _Container container_type; @@ -376,14 +376,14 @@ swap(queue<_Tp, _Container>& __x, queue<_Tp, _Container>& __y) } template <class _Tp, class _Container, class _Alloc> -struct _LIBCPP_TYPE_VIS uses_allocator<queue<_Tp, _Container>, _Alloc> +struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<queue<_Tp, _Container>, _Alloc> : public uses_allocator<_Container, _Alloc> { }; template <class _Tp, class _Container = vector<_Tp>, class _Compare = less<typename _Container::value_type> > -class _LIBCPP_TYPE_VIS priority_queue +class _LIBCPP_TYPE_VIS_ONLY priority_queue { public: typedef _Container container_type; @@ -707,7 +707,7 @@ swap(priority_queue<_Tp, _Container, _Compare>& __x, } template <class _Tp, class _Container, class _Compare, class _Alloc> -struct _LIBCPP_TYPE_VIS uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc> +struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<priority_queue<_Tp, _Container, _Compare>, _Alloc> : public uses_allocator<_Container, _Alloc> { }; diff --git a/system/include/libcxx/random b/system/include/libcxx/random index 2e7a4854..c0db1aba 100644 --- a/system/include/libcxx/random +++ b/system/include/libcxx/random @@ -1813,7 +1813,7 @@ struct __lce_ta<__a, __c, __m, (unsigned short)(~0), __b> }; template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> -class _LIBCPP_TYPE_VIS linear_congruential_engine; +class _LIBCPP_TYPE_VIS_ONLY linear_congruential_engine; template <class _CharT, class _Traits, class _Up, _Up _Ap, _Up _Cp, _Up _Np> @@ -1829,7 +1829,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, linear_congruential_engine<_Up, _Ap, _Cp, _Np>& __x); template <class _UIntType, _UIntType __a, _UIntType __c, _UIntType __m> -class _LIBCPP_TYPE_VIS linear_congruential_engine +class _LIBCPP_TYPE_VIS_ONLY linear_congruential_engine { public: // types @@ -2011,7 +2011,7 @@ typedef minstd_rand default_random_engine; template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, _UIntType __a, size_t __u, _UIntType __d, size_t __s, _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> -class _LIBCPP_TYPE_VIS mersenne_twister_engine; +class _LIBCPP_TYPE_VIS_ONLY mersenne_twister_engine; template <class _UI, size_t _Wp, size_t _Np, size_t _Mp, size_t _Rp, _UI _Ap, size_t _Up, _UI _Dp, size_t _Sp, @@ -2053,7 +2053,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, template <class _UIntType, size_t __w, size_t __n, size_t __m, size_t __r, _UIntType __a, size_t __u, _UIntType __d, size_t __s, _UIntType __b, size_t __t, _UIntType __c, size_t __l, _UIntType __f> -class _LIBCPP_TYPE_VIS mersenne_twister_engine +class _LIBCPP_TYPE_VIS_ONLY mersenne_twister_engine { public: // types @@ -2499,7 +2499,7 @@ typedef mersenne_twister_engine<uint_fast64_t, 64, 312, 156, 31, // subtract_with_carry_engine template<class _UIntType, size_t __w, size_t __s, size_t __r> -class _LIBCPP_TYPE_VIS subtract_with_carry_engine; +class _LIBCPP_TYPE_VIS_ONLY subtract_with_carry_engine; template<class _UI, size_t _Wp, size_t _Sp, size_t _Rp> bool @@ -2527,7 +2527,7 @@ operator>>(basic_istream<_CharT, _Traits>& __is, subtract_with_carry_engine<_UI, _Wp, _Sp, _Rp>& __x); template<class _UIntType, size_t __w, size_t __s, size_t __r> -class _LIBCPP_TYPE_VIS subtract_with_carry_engine +class _LIBCPP_TYPE_VIS_ONLY subtract_with_carry_engine { public: // types @@ -2810,7 +2810,7 @@ typedef subtract_with_carry_engine<uint_fast64_t, 48, 5, 12> ranlux48_base; // discard_block_engine template<class _Engine, size_t __p, size_t __r> -class _LIBCPP_TYPE_VIS discard_block_engine +class _LIBCPP_TYPE_VIS_ONLY discard_block_engine { _Engine __e_; int __n_; @@ -2983,7 +2983,7 @@ typedef discard_block_engine<ranlux48_base, 389, 11> ranlux48; // independent_bits_engine template<class _Engine, size_t __w, class _UIntType> -class _LIBCPP_TYPE_VIS independent_bits_engine +class _LIBCPP_TYPE_VIS_ONLY independent_bits_engine { template <class _UI, _UI _R0, size_t _Wp, size_t _Mp> class __get_n @@ -3246,7 +3246,7 @@ public: }; template<class _Engine, size_t __k> -class _LIBCPP_TYPE_VIS shuffle_order_engine +class _LIBCPP_TYPE_VIS_ONLY shuffle_order_engine { static_assert(0 < __k, "shuffle_order_engine invalid parameters"); public: @@ -3475,7 +3475,9 @@ typedef shuffle_order_engine<minstd_rand0, 256> knuth_b; class _LIBCPP_TYPE_VIS random_device { +#if !defined(_WIN32) int __f_; +#endif // defined(_WIN32) public: // types typedef unsigned result_type; @@ -3507,7 +3509,7 @@ private: // seed_seq -class _LIBCPP_TYPE_VIS seed_seq +class _LIBCPP_TYPE_VIS_ONLY seed_seq { public: // types @@ -3521,7 +3523,7 @@ private: public: // constructors _LIBCPP_INLINE_VISIBILITY - seed_seq() {} + seed_seq() _NOEXCEPT {} #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template<class _Tp> _LIBCPP_INLINE_VISIBILITY @@ -3539,7 +3541,7 @@ public: // property functions _LIBCPP_INLINE_VISIBILITY - size_t size() const {return __v_.size();} + size_t size() const _NOEXCEPT {return __v_.size();} template<class _OutputIterator> _LIBCPP_INLINE_VISIBILITY void param(_OutputIterator __dest) const @@ -3684,13 +3686,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // uniform_real_distribution template<class _RealType = double> -class _LIBCPP_TYPE_VIS uniform_real_distribution +class _LIBCPP_TYPE_VIS_ONLY uniform_real_distribution { public: // types typedef _RealType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __a_; result_type __b_; @@ -3805,13 +3807,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // bernoulli_distribution -class _LIBCPP_TYPE_VIS bernoulli_distribution +class _LIBCPP_TYPE_VIS_ONLY bernoulli_distribution { public: // types typedef bool result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { double __p_; public: @@ -3914,13 +3916,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, bernoulli_distribution& __x) // binomial_distribution template<class _IntType = int> -class _LIBCPP_TYPE_VIS binomial_distribution +class _LIBCPP_TYPE_VIS_ONLY binomial_distribution { public: // types typedef _IntType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __t_; double __p_; @@ -4079,13 +4081,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // exponential_distribution template<class _RealType = double> -class _LIBCPP_TYPE_VIS exponential_distribution +class _LIBCPP_TYPE_VIS_ONLY exponential_distribution { public: // types typedef _RealType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __lambda_; public: @@ -4194,13 +4196,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // normal_distribution template<class _RealType = double> -class _LIBCPP_TYPE_VIS normal_distribution +class _LIBCPP_TYPE_VIS_ONLY normal_distribution { public: // types typedef _RealType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __mean_; result_type __stddev_; @@ -4362,13 +4364,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // lognormal_distribution template<class _RealType = double> -class _LIBCPP_TYPE_VIS lognormal_distribution +class _LIBCPP_TYPE_VIS_ONLY lognormal_distribution { public: // types typedef _RealType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { normal_distribution<result_type> __nd_; public: @@ -4487,13 +4489,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // poisson_distribution template<class _IntType = int> -class _LIBCPP_TYPE_VIS poisson_distribution +class _LIBCPP_TYPE_VIS_ONLY poisson_distribution { public: // types typedef _IntType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { double __mean_; double __s_; @@ -4718,13 +4720,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // weibull_distribution template<class _RealType = double> -class _LIBCPP_TYPE_VIS weibull_distribution +class _LIBCPP_TYPE_VIS_ONLY weibull_distribution { public: // types typedef _RealType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __a_; result_type __b_; @@ -4832,13 +4834,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, } template<class _RealType = double> -class _LIBCPP_TYPE_VIS extreme_value_distribution +class _LIBCPP_TYPE_VIS_ONLY extreme_value_distribution { public: // types typedef _RealType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __a_; result_type __b_; @@ -4953,13 +4955,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // gamma_distribution template<class _RealType = double> -class _LIBCPP_TYPE_VIS gamma_distribution +class _LIBCPP_TYPE_VIS_ONLY gamma_distribution { public: // types typedef _RealType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __alpha_; result_type __beta_; @@ -5125,13 +5127,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // negative_binomial_distribution template<class _IntType = int> -class _LIBCPP_TYPE_VIS negative_binomial_distribution +class _LIBCPP_TYPE_VIS_ONLY negative_binomial_distribution { public: // types typedef _IntType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __k_; double __p_; @@ -5260,13 +5262,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // geometric_distribution template<class _IntType = int> -class _LIBCPP_TYPE_VIS geometric_distribution +class _LIBCPP_TYPE_VIS_ONLY geometric_distribution { public: // types typedef _IntType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { double __p_; public: @@ -5362,13 +5364,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // chi_squared_distribution template<class _RealType = double> -class _LIBCPP_TYPE_VIS chi_squared_distribution +class _LIBCPP_TYPE_VIS_ONLY chi_squared_distribution { public: // types typedef _RealType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __n_; public: @@ -5468,13 +5470,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // cauchy_distribution template<class _RealType = double> -class _LIBCPP_TYPE_VIS cauchy_distribution +class _LIBCPP_TYPE_VIS_ONLY cauchy_distribution { public: // types typedef _RealType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __a_; result_type __b_; @@ -5591,13 +5593,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // fisher_f_distribution template<class _RealType = double> -class _LIBCPP_TYPE_VIS fisher_f_distribution +class _LIBCPP_TYPE_VIS_ONLY fisher_f_distribution { public: // types typedef _RealType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __m_; result_type __n_; @@ -5713,13 +5715,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // student_t_distribution template<class _RealType = double> -class _LIBCPP_TYPE_VIS student_t_distribution +class _LIBCPP_TYPE_VIS_ONLY student_t_distribution { public: // types typedef _RealType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { result_type __n_; public: @@ -5826,13 +5828,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // discrete_distribution template<class _IntType = int> -class _LIBCPP_TYPE_VIS discrete_distribution +class _LIBCPP_TYPE_VIS_ONLY discrete_distribution { public: // types typedef _IntType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { vector<double> __p_; public: @@ -5901,8 +5903,8 @@ public: discrete_distribution(size_t __nw, double __xmin, double __xmax, _UnaryOperation __fw) : __p_(__nw, __xmin, __xmax, __fw) {} - explicit discrete_distribution(const param_type& __p) _LIBCPP_INLINE_VISIBILITY + explicit discrete_distribution(const param_type& __p) : __p_(__p) {} _LIBCPP_INLINE_VISIBILITY void reset() {} @@ -6057,13 +6059,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // piecewise_constant_distribution template<class _RealType = double> -class _LIBCPP_TYPE_VIS piecewise_constant_distribution +class _LIBCPP_TYPE_VIS_ONLY piecewise_constant_distribution { public: // types typedef _RealType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { vector<result_type> __b_; vector<result_type> __densities_; @@ -6381,13 +6383,13 @@ operator>>(basic_istream<_CharT, _Traits>& __is, // piecewise_linear_distribution template<class _RealType = double> -class _LIBCPP_TYPE_VIS piecewise_linear_distribution +class _LIBCPP_TYPE_VIS_ONLY piecewise_linear_distribution { public: // types typedef _RealType result_type; - class _LIBCPP_TYPE_VIS param_type + class _LIBCPP_TYPE_VIS_ONLY param_type { vector<result_type> __b_; vector<result_type> __densities_; diff --git a/system/include/libcxx/ratio b/system/include/libcxx/ratio index f4e741e8..48dcd81c 100644 --- a/system/include/libcxx/ratio +++ b/system/include/libcxx/ratio @@ -231,7 +231,7 @@ public: }; template <intmax_t _Num, intmax_t _Den = 1> -class _LIBCPP_TYPE_VIS ratio +class _LIBCPP_TYPE_VIS_ONLY ratio { static_assert(__static_abs<_Num>::value >= 0, "ratio numerator is out of range"); static_assert(_Den != 0, "ratio divide by 0"); @@ -292,7 +292,7 @@ template <class _R1, class _R2> using ratio_multiply #else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES template <class _R1, class _R2> -struct _LIBCPP_TYPE_VIS ratio_multiply +struct _LIBCPP_TYPE_VIS_ONLY ratio_multiply : public __ratio_multiply<_R1, _R2>::type {}; #endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES @@ -319,7 +319,7 @@ template <class _R1, class _R2> using ratio_divide #else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES template <class _R1, class _R2> -struct _LIBCPP_TYPE_VIS ratio_divide +struct _LIBCPP_TYPE_VIS_ONLY ratio_divide : public __ratio_divide<_R1, _R2>::type {}; #endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES @@ -354,7 +354,7 @@ template <class _R1, class _R2> using ratio_add #else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES template <class _R1, class _R2> -struct _LIBCPP_TYPE_VIS ratio_add +struct _LIBCPP_TYPE_VIS_ONLY ratio_add : public __ratio_add<_R1, _R2>::type {}; #endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES @@ -389,7 +389,7 @@ template <class _R1, class _R2> using ratio_subtract #else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES template <class _R1, class _R2> -struct _LIBCPP_TYPE_VIS ratio_subtract +struct _LIBCPP_TYPE_VIS_ONLY ratio_subtract : public __ratio_subtract<_R1, _R2>::type {}; #endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES @@ -397,11 +397,11 @@ struct _LIBCPP_TYPE_VIS ratio_subtract // ratio_equal template <class _R1, class _R2> -struct _LIBCPP_TYPE_VIS ratio_equal +struct _LIBCPP_TYPE_VIS_ONLY ratio_equal : public integral_constant<bool, _R1::num == _R2::num && _R1::den == _R2::den> {}; template <class _R1, class _R2> -struct _LIBCPP_TYPE_VIS ratio_not_equal +struct _LIBCPP_TYPE_VIS_ONLY ratio_not_equal : public integral_constant<bool, !ratio_equal<_R1, _R2>::value> {}; // ratio_less @@ -460,19 +460,19 @@ struct __ratio_less<_R1, _R2, -1LL, -1LL> }; template <class _R1, class _R2> -struct _LIBCPP_TYPE_VIS ratio_less +struct _LIBCPP_TYPE_VIS_ONLY ratio_less : public integral_constant<bool, __ratio_less<_R1, _R2>::value> {}; template <class _R1, class _R2> -struct _LIBCPP_TYPE_VIS ratio_less_equal +struct _LIBCPP_TYPE_VIS_ONLY ratio_less_equal : public integral_constant<bool, !ratio_less<_R2, _R1>::value> {}; template <class _R1, class _R2> -struct _LIBCPP_TYPE_VIS ratio_greater +struct _LIBCPP_TYPE_VIS_ONLY ratio_greater : public integral_constant<bool, ratio_less<_R2, _R1>::value> {}; template <class _R1, class _R2> -struct _LIBCPP_TYPE_VIS ratio_greater_equal +struct _LIBCPP_TYPE_VIS_ONLY ratio_greater_equal : public integral_constant<bool, !ratio_less<_R1, _R2>::value> {}; template <class _R1, class _R2> diff --git a/system/include/libcxx/readme.txt b/system/include/libcxx/readme.txt index 7687e5b2..ae8090fd 100644 --- a/system/include/libcxx/readme.txt +++ b/system/include/libcxx/readme.txt @@ -1 +1 @@ -These files are from libc++, svn revision 187959, 2013-08-08. +These files are from libc++, svn revision 194185, 2013-11-07. diff --git a/system/include/libcxx/regex b/system/include/libcxx/regex index bde3af7e..ffe39cf1 100644 --- a/system/include/libcxx/regex +++ b/system/include/libcxx/regex @@ -925,7 +925,7 @@ public: }; template <class _CharT> -struct _LIBCPP_TYPE_VIS regex_traits +struct _LIBCPP_TYPE_VIS_ONLY regex_traits { public: typedef _CharT char_type; @@ -970,7 +970,7 @@ public: bool isctype(char_type __c, char_class_type __m) const; _LIBCPP_INLINE_VISIBILITY int value(char_type __ch, int __radix) const - {return __value(__ch, __radix);} + {return __regex_traits_value(__ch, __radix);} locale_type imbue(locale_type __l); _LIBCPP_INLINE_VISIBILITY locale_type getloc()const {return __loc_;} @@ -1001,11 +1001,11 @@ private: __lookup_classname(_ForwardIterator __f, _ForwardIterator __l, bool __icase, wchar_t) const; - static int __value(unsigned char __ch, int __radix); + static int __regex_traits_value(unsigned char __ch, int __radix); _LIBCPP_INLINE_VISIBILITY - int __value(char __ch, int __radix) const - {return __value(static_cast<unsigned char>(__ch), __radix);} - int __value(wchar_t __ch, int __radix) const; + int __regex_traits_value(char __ch, int __radix) const + {return __regex_traits_value(static_cast<unsigned char>(__ch), __radix);} + int __regex_traits_value(wchar_t __ch, int __radix) const; }; template <class _CharT> @@ -1100,7 +1100,7 @@ regex_traits<_CharT>::__transform_primary(_ForwardIterator __f, // lookup_collatename is very FreeBSD-specific -string __get_collation_name(const char* __s); +_LIBCPP_FUNC_VIS string __get_collation_name(const char* __s); template <class _CharT> template <class _ForwardIterator> @@ -1161,7 +1161,7 @@ regex_traits<_CharT>::__lookup_collatename(_ForwardIterator __f, // lookup_classname -ctype_base::mask __get_classname(const char* __s, bool __icase); +ctype_base::mask _LIBCPP_FUNC_VIS __get_classname(const char* __s, bool __icase); template <class _CharT> template <class _ForwardIterator> @@ -1207,7 +1207,7 @@ regex_traits<_CharT>::isctype(char_type __c, char_class_type __m) const template <class _CharT> int -regex_traits<_CharT>::__value(unsigned char __ch, int __radix) +regex_traits<_CharT>::__regex_traits_value(unsigned char __ch, int __radix) { if ((__ch & 0xF8u) == 0x30) // '0' <= __ch && __ch <= '7' return __ch - '0'; @@ -1228,18 +1228,18 @@ regex_traits<_CharT>::__value(unsigned char __ch, int __radix) template <class _CharT> inline _LIBCPP_INLINE_VISIBILITY int -regex_traits<_CharT>::__value(wchar_t __ch, int __radix) const +regex_traits<_CharT>::__regex_traits_value(wchar_t __ch, int __radix) const { - return __value(static_cast<unsigned char>(__ct_->narrow(__ch, char_type())), __radix); + return __regex_traits_value(static_cast<unsigned char>(__ct_->narrow(__ch, char_type())), __radix); } template <class _CharT> class __node; -template <class _BidirectionalIterator> class _LIBCPP_TYPE_VIS sub_match; +template <class _BidirectionalIterator> class _LIBCPP_TYPE_VIS_ONLY sub_match; template <class _BidirectionalIterator, class _Allocator = allocator<sub_match<_BidirectionalIterator> > > -class _LIBCPP_TYPE_VIS match_results; +class _LIBCPP_TYPE_VIS_ONLY match_results; template <class _CharT> struct __state @@ -2014,6 +2014,9 @@ public: virtual void __exec(__state&) const; }; +template <> _LIBCPP_FUNC_VIS void __match_any_but_newline<char>::__exec(__state&) const; +template <> _LIBCPP_FUNC_VIS void __match_any_but_newline<wchar_t>::__exec(__state&) const; + // __match_char template <class _CharT> @@ -2415,7 +2418,7 @@ __exit: template <class _CharT, class _Traits> class __lookahead; template <class _CharT, class _Traits = regex_traits<_CharT> > -class _LIBCPP_TYPE_VIS basic_regex +class _LIBCPP_TYPE_VIS_ONLY basic_regex { public: // types: @@ -3782,7 +3785,7 @@ basic_regex<_CharT, _Traits>::__parse_expression_term(_ForwardIterator __first, } __ml->__add_range(_VSTD::move(__start_range), _VSTD::move(__end_range)); } - else + else if (!__start_range.empty()) { if (__start_range.size() == 1) __ml->__add_char(__start_range[0]); @@ -3790,7 +3793,7 @@ basic_regex<_CharT, _Traits>::__parse_expression_term(_ForwardIterator __first, __ml->__add_digraph(__start_range[0], __start_range[1]); } } - else + else if (!__start_range.empty()) { if (__start_range.size() == 1) __ml->__add_char(__start_range[0]); @@ -4781,7 +4784,7 @@ typedef basic_regex<wchar_t> wregex; // sub_match template <class _BidirectionalIterator> -class _LIBCPP_TYPE_VIS sub_match +class _LIBCPP_TYPE_VIS_ONLY sub_match : public pair<_BidirectionalIterator, _BidirectionalIterator> { public: @@ -5204,7 +5207,7 @@ operator<<(basic_ostream<_CharT, _ST>& __os, const sub_match<_BiIter>& __m) } template <class _BidirectionalIterator, class _Allocator> -class _LIBCPP_TYPE_VIS match_results +class _LIBCPP_TYPE_VIS_ONLY match_results { public: typedef _Allocator allocator_type; @@ -6007,7 +6010,7 @@ regex_match(const basic_string<_CharT, _ST, _SA>& __s, template <class _BidirectionalIterator, class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type, class _Traits = regex_traits<_CharT> > -class _LIBCPP_TYPE_VIS regex_iterator +class _LIBCPP_TYPE_VIS_ONLY regex_iterator { public: typedef basic_regex<_CharT, _Traits> regex_type; @@ -6119,7 +6122,7 @@ typedef regex_iterator<wstring::const_iterator> wsregex_iterator; template <class _BidirectionalIterator, class _CharT = typename iterator_traits<_BidirectionalIterator>::value_type, class _Traits = regex_traits<_CharT> > -class _LIBCPP_TYPE_VIS regex_token_iterator +class _LIBCPP_TYPE_VIS_ONLY regex_token_iterator { public: typedef basic_regex<_CharT, _Traits> regex_type; diff --git a/system/include/libcxx/scoped_allocator b/system/include/libcxx/scoped_allocator index 92532342..aa8bece6 100644 --- a/system/include/libcxx/scoped_allocator +++ b/system/include/libcxx/scoped_allocator @@ -365,7 +365,7 @@ struct __outermost<_Alloc, true> }; template <class _OuterAlloc, class... _InnerAllocs> -class _LIBCPP_TYPE_VIS scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...> +class _LIBCPP_TYPE_VIS_ONLY scoped_allocator_adaptor<_OuterAlloc, _InnerAllocs...> : public __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> { typedef __scoped_allocator_storage<_OuterAlloc, _InnerAllocs...> base; diff --git a/system/include/libcxx/set b/system/include/libcxx/set index 11ea9658..a537c5fe 100644 --- a/system/include/libcxx/set +++ b/system/include/libcxx/set @@ -66,6 +66,11 @@ public: set(initializer_list<value_type> il, const value_compare& comp = value_compare()); set(initializer_list<value_type> il, const value_compare& comp, const allocator_type& a); + template <class InputIterator> + set(InputIterator first, InputIterator last, const allocator_type& a) + : set(first, last, Compare(), a) {} // C++14 + set(initializer_list<value_type> il, const allocator_type& a) + : set(il, Compare(), a) {} // C++14 ~set(); set& operator=(const set& s); @@ -129,13 +134,33 @@ public: // set operations: iterator find(const key_type& k); const_iterator find(const key_type& k) const; + template<typename K> + iterator find(const K& x); + template<typename K> + const_iterator find(const K& x) const; // C++14 + template<typename K> + size_type count(const K& x) const; // C++14 + size_type count(const key_type& k) const; iterator lower_bound(const key_type& k); const_iterator lower_bound(const key_type& k) const; + template<typename K> + iterator lower_bound(const K& x); // C++14 + template<typename K> + const_iterator lower_bound(const K& x) const; // C++14 + iterator upper_bound(const key_type& k); const_iterator upper_bound(const key_type& k) const; + template<typename K> + iterator upper_bound(const K& x); // C++14 + template<typename K> + const_iterator upper_bound(const K& x) const; // C++14 pair<iterator,iterator> equal_range(const key_type& k); pair<const_iterator,const_iterator> equal_range(const key_type& k) const; + template<typename K> + pair<iterator,iterator> equal_range(const K& x); // C++14 + template<typename K> + pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 }; template <class Key, class Compare, class Allocator> @@ -222,6 +247,11 @@ public: multiset(initializer_list<value_type> il, const value_compare& comp = value_compare()); multiset(initializer_list<value_type> il, const value_compare& comp, const allocator_type& a); + template <class InputIterator> + multiset(InputIterator first, InputIterator last, const allocator_type& a) + : set(first, last, Compare(), a) {} // C++14 + multiset(initializer_list<value_type> il, const allocator_type& a) + : set(il, Compare(), a) {} // C++14 ~multiset(); multiset& operator=(const multiset& s); @@ -285,13 +315,32 @@ public: // set operations: iterator find(const key_type& k); const_iterator find(const key_type& k) const; + template<typename K> + iterator find(const K& x); + template<typename K> + const_iterator find(const K& x) const; // C++14 + size_type count(const key_type& k) const; iterator lower_bound(const key_type& k); const_iterator lower_bound(const key_type& k) const; + template<typename K> + iterator lower_bound(const K& x); // C++14 + template<typename K> + const_iterator lower_bound(const K& x) const; // C++14 + iterator upper_bound(const key_type& k); const_iterator upper_bound(const key_type& k) const; + template<typename K> + iterator upper_bound(const K& x); // C++14 + template<typename K> + const_iterator upper_bound(const K& x) const; // C++14 + pair<iterator,iterator> equal_range(const key_type& k); pair<const_iterator,const_iterator> equal_range(const key_type& k) const; + template<typename K> + pair<iterator,iterator> equal_range(const K& x); // C++14 + template<typename K> + pair<const_iterator,const_iterator> equal_range(const K& x) const; // C++14 }; template <class Key, class Compare, class Allocator> @@ -346,7 +395,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _Key, class _Compare = less<_Key>, class _Allocator = allocator<_Key> > -class _LIBCPP_TYPE_VIS set +class _LIBCPP_TYPE_VIS_ONLY set { public: // types: @@ -403,6 +452,13 @@ public: insert(__f, __l); } +#if _LIBCPP_STD_VER > 11 + template <class _InputIterator> + _LIBCPP_INLINE_VISIBILITY + set(_InputIterator __f, _InputIterator __l, const allocator_type& __a) + : set(__f, __l, key_compare(), __a) {} +#endif + _LIBCPP_INLINE_VISIBILITY set(const set& __s) : __tree_(__s.__tree_) @@ -455,6 +511,12 @@ public: insert(__il.begin(), __il.end()); } +#if _LIBCPP_STD_VER > 11 + _LIBCPP_INLINE_VISIBILITY + set(initializer_list<value_type> __il, const allocator_type& __a) + : set(__il, key_compare(), __a) {} +#endif + _LIBCPP_INLINE_VISIBILITY set& operator=(initializer_list<value_type> __il) { @@ -579,6 +641,17 @@ public: iterator find(const key_type& __k) {return __tree_.find(__k);} _LIBCPP_INLINE_VISIBILITY const_iterator find(const key_type& __k) const {return __tree_.find(__k);} +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + find(const _K2& __k) {return __tree_.find(__k);} + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + find(const _K2& __k) const {return __tree_.find(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY size_type count(const key_type& __k) const {return __tree_.__count_unique(__k);} @@ -588,18 +661,51 @@ public: _LIBCPP_INLINE_VISIBILITY const_iterator lower_bound(const key_type& __k) const {return __tree_.lower_bound(__k);} +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} + + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY iterator upper_bound(const key_type& __k) {return __tree_.upper_bound(__k);} _LIBCPP_INLINE_VISIBILITY const_iterator upper_bound(const key_type& __k) const {return __tree_.upper_bound(__k);} +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,iterator>::type + upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,const_iterator>::type + upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY pair<iterator,iterator> equal_range(const key_type& __k) {return __tree_.__equal_range_unique(__k);} _LIBCPP_INLINE_VISIBILITY pair<const_iterator,const_iterator> equal_range(const key_type& __k) const {return __tree_.__equal_range_unique(__k);} +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type + equal_range(const _K2& __k) {return __tree_.__equal_range_unique(__k);} + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename enable_if<__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type + equal_range(const _K2& __k) const {return __tree_.__equal_range_unique(__k);} +#endif }; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -685,7 +791,7 @@ swap(set<_Key, _Compare, _Allocator>& __x, template <class _Key, class _Compare = less<_Key>, class _Allocator = allocator<_Key> > -class _LIBCPP_TYPE_VIS multiset +class _LIBCPP_TYPE_VIS_ONLY multiset { public: // types: @@ -734,6 +840,13 @@ public: insert(__f, __l); } +#if _LIBCPP_STD_VER > 11 + template <class _InputIterator> + _LIBCPP_INLINE_VISIBILITY + multiset(_InputIterator __f, _InputIterator __l, const allocator_type& __a) + : multiset(__f, __l, key_compare(), __a) {} +#endif + template <class _InputIterator> _LIBCPP_INLINE_VISIBILITY multiset(_InputIterator __f, _InputIterator __l, @@ -793,6 +906,12 @@ public: insert(__il.begin(), __il.end()); } +#if _LIBCPP_STD_VER > 11 + _LIBCPP_INLINE_VISIBILITY + multiset(initializer_list<value_type> __il, const allocator_type& __a) + : multiset(__il, key_compare(), __a) {} +#endif + _LIBCPP_INLINE_VISIBILITY multiset& operator=(initializer_list<value_type> __il) { @@ -917,27 +1036,72 @@ public: iterator find(const key_type& __k) {return __tree_.find(__k);} _LIBCPP_INLINE_VISIBILITY const_iterator find(const key_type& __k) const {return __tree_.find(__k);} +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type + find(const _K2& __k) {return __tree_.find(__k);} + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type + find(const _K2& __k) const {return __tree_.find(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY size_type count(const key_type& __k) const {return __tree_.__count_multi(__k);} + _LIBCPP_INLINE_VISIBILITY iterator lower_bound(const key_type& __k) {return __tree_.lower_bound(__k);} _LIBCPP_INLINE_VISIBILITY const_iterator lower_bound(const key_type& __k) const {return __tree_.lower_bound(__k);} +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type + lower_bound(const _K2& __k) {return __tree_.lower_bound(__k);} + + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type + lower_bound(const _K2& __k) const {return __tree_.lower_bound(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY iterator upper_bound(const key_type& __k) {return __tree_.upper_bound(__k);} _LIBCPP_INLINE_VISIBILITY const_iterator upper_bound(const key_type& __k) const {return __tree_.upper_bound(__k);} +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,iterator>::type + upper_bound(const _K2& __k) {return __tree_.upper_bound(__k);} + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,const_iterator>::type + upper_bound(const _K2& __k) const {return __tree_.upper_bound(__k);} +#endif + _LIBCPP_INLINE_VISIBILITY pair<iterator,iterator> equal_range(const key_type& __k) {return __tree_.__equal_range_multi(__k);} _LIBCPP_INLINE_VISIBILITY pair<const_iterator,const_iterator> equal_range(const key_type& __k) const {return __tree_.__equal_range_multi(__k);} +#if _LIBCPP_STD_VER > 11 + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,pair<iterator,iterator>>::type + equal_range(const _K2& __k) {return __tree_.__equal_range_multi(__k);} + template <typename _K2> + _LIBCPP_INLINE_VISIBILITY + typename _VSTD::enable_if<_VSTD::__is_transparent<_Compare, _K2>::value,pair<const_iterator,const_iterator>>::type + equal_range(const _K2& __k) const {return __tree_.__equal_range_multi(__k);} +#endif }; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES diff --git a/system/include/libcxx/shared_mutex b/system/include/libcxx/shared_mutex new file mode 100644 index 00000000..5b1f53aa --- /dev/null +++ b/system/include/libcxx/shared_mutex @@ -0,0 +1,419 @@ +// -*- C++ -*- +//===------------------------ shared_mutex --------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_SHARED_MUTEX +#define _LIBCPP_SHARED_MUTEX + +/* + shared_mutex synopsis + +// C++1y + +namespace std +{ + +class shared_mutex +{ +public: + shared_mutex(); + ~shared_mutex(); + + shared_mutex(const shared_mutex&) = delete; + shared_mutex& operator=(const shared_mutex&) = delete; + + // Exclusive ownership + void lock(); // blocking + bool try_lock(); + template <class Rep, class Period> + bool try_lock_for(const chrono::duration<Rep, Period>& rel_time); + template <class Clock, class Duration> + bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time); + void unlock(); + + // Shared ownership + void lock_shared(); // blocking + bool try_lock_shared(); + template <class Rep, class Period> + bool + try_lock_shared_for(const chrono::duration<Rep, Period>& rel_time); + template <class Clock, class Duration> + bool + try_lock_shared_until(const chrono::time_point<Clock, Duration>& abs_time); + void unlock_shared(); +}; + +template <class Mutex> +class shared_lock +{ +public: + typedef Mutex mutex_type; + + // Shared locking + shared_lock() noexcept; + explicit shared_lock(mutex_type& m); // blocking + shared_lock(mutex_type& m, defer_lock_t) noexcept; + shared_lock(mutex_type& m, try_to_lock_t); + shared_lock(mutex_type& m, adopt_lock_t); + template <class Clock, class Duration> + shared_lock(mutex_type& m, + const chrono::time_point<Clock, Duration>& abs_time); + template <class Rep, class Period> + shared_lock(mutex_type& m, + const chrono::duration<Rep, Period>& rel_time); + ~shared_lock(); + + shared_lock(shared_lock const&) = delete; + shared_lock& operator=(shared_lock const&) = delete; + + shared_lock(shared_lock&& u) noexcept; + shared_lock& operator=(shared_lock&& u) noexcept; + + void lock(); // blocking + bool try_lock(); + template <class Rep, class Period> + bool try_lock_for(const chrono::duration<Rep, Period>& rel_time); + template <class Clock, class Duration> + bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time); + void unlock(); + + // Setters + void swap(shared_lock& u) noexcept; + mutex_type* release() noexcept; + + // Getters + bool owns_lock() const noexcept; + explicit operator bool () const noexcept; + mutex_type* mutex() const noexcept; +}; + +template <class Mutex> + void swap(shared_lock<Mutex>& x, shared_lock<Mutex>& y) noexcept; + +} // std + +*/ + +#include <__config> + +#if _LIBCPP_STD_VER > 11 || defined(_LIBCPP_BUILDING_SHARED_MUTEX) + +#include <__mutex_base> + +#include <__undef_min_max> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +class _LIBCPP_TYPE_VIS shared_mutex +{ + mutex __mut_; + condition_variable __gate1_; + condition_variable __gate2_; + unsigned __state_; + + static const unsigned __write_entered_ = 1U << (sizeof(unsigned)*__CHAR_BIT__ - 1); + static const unsigned __n_readers_ = ~__write_entered_; +public: + shared_mutex(); + _LIBCPP_INLINE_VISIBILITY ~shared_mutex() = default; + + shared_mutex(const shared_mutex&) = delete; + shared_mutex& operator=(const shared_mutex&) = delete; + + // Exclusive ownership + void lock(); + bool try_lock(); + template <class _Rep, class _Period> + _LIBCPP_INLINE_VISIBILITY + bool + try_lock_for(const chrono::duration<_Rep, _Period>& __rel_time) + { + return try_lock_until(chrono::steady_clock::now() + __rel_time); + } + template <class _Clock, class _Duration> + bool + try_lock_until(const chrono::time_point<_Clock, _Duration>& __abs_time); + void unlock(); + + // Shared ownership + void lock_shared(); + bool try_lock_shared(); + template <class _Rep, class _Period> + _LIBCPP_INLINE_VISIBILITY + bool + try_lock_shared_for(const chrono::duration<_Rep, _Period>& __rel_time) + { + return try_lock_shared_until(chrono::steady_clock::now() + __rel_time); + } + template <class _Clock, class _Duration> + bool + try_lock_shared_until(const chrono::time_point<_Clock, _Duration>& __abs_time); + void unlock_shared(); +}; + +template <class _Clock, class _Duration> +bool +shared_mutex::try_lock_until( + const chrono::time_point<_Clock, _Duration>& __abs_time) +{ + unique_lock<mutex> __lk(__mut_); + if (__state_ & __write_entered_) + { + while (true) + { + cv_status __status = __gate1_.wait_until(__lk, __abs_time); + if ((__state_ & __write_entered_) == 0) + break; + if (__status == cv_status::timeout) + return false; + } + } + __state_ |= __write_entered_; + if (__state_ & __n_readers_) + { + while (true) + { + cv_status __status = __gate2_.wait_until(__lk, __abs_time); + if ((__state_ & __n_readers_) == 0) + break; + if (__status == cv_status::timeout) + { + __state_ &= ~__write_entered_; + return false; + } + } + } + return true; +} + +template <class _Clock, class _Duration> +bool +shared_mutex::try_lock_shared_until( + const chrono::time_point<_Clock, _Duration>& __abs_time) +{ + unique_lock<mutex> __lk(__mut_); + if ((__state_ & __write_entered_) || (__state_ & __n_readers_) == __n_readers_) + { + while (true) + { + cv_status status = __gate1_.wait_until(__lk, __abs_time); + if ((__state_ & __write_entered_) == 0 && + (__state_ & __n_readers_) < __n_readers_) + break; + if (status == cv_status::timeout) + return false; + } + } + unsigned __num_readers = (__state_ & __n_readers_) + 1; + __state_ &= ~__n_readers_; + __state_ |= __num_readers; + return true; +} + +template <class _Mutex> +class shared_lock +{ +public: + typedef _Mutex mutex_type; + +private: + mutex_type* __m_; + bool __owns_; + +public: + _LIBCPP_INLINE_VISIBILITY + shared_lock() noexcept + : __m_(nullptr), + __owns_(false) + {} + + _LIBCPP_INLINE_VISIBILITY + explicit shared_lock(mutex_type& __m) + : __m_(&__m), + __owns_(true) + {__m_->lock_shared();} + + _LIBCPP_INLINE_VISIBILITY + shared_lock(mutex_type& __m, defer_lock_t) noexcept + : __m_(&__m), + __owns_(false) + {} + + _LIBCPP_INLINE_VISIBILITY + shared_lock(mutex_type& __m, try_to_lock_t) + : __m_(&__m), + __owns_(__m.try_lock_shared()) + {} + + _LIBCPP_INLINE_VISIBILITY + shared_lock(mutex_type& __m, adopt_lock_t) + : __m_(&__m), + __owns_(true) + {} + + template <class _Clock, class _Duration> + _LIBCPP_INLINE_VISIBILITY + shared_lock(mutex_type& __m, + const chrono::time_point<_Clock, _Duration>& __abs_time) + : __m_(&__m), + __owns_(__m.try_lock_shared_until(__abs_time)) + {} + + template <class _Rep, class _Period> + _LIBCPP_INLINE_VISIBILITY + shared_lock(mutex_type& __m, + const chrono::duration<_Rep, _Period>& __rel_time) + : __m_(&__m), + __owns_(__m.try_lock_shared_for(__rel_time)) + {} + + _LIBCPP_INLINE_VISIBILITY + ~shared_lock() + { + if (__owns_) + __m_->unlock_shared(); + } + + shared_lock(shared_lock const&) = delete; + shared_lock& operator=(shared_lock const&) = delete; + + _LIBCPP_INLINE_VISIBILITY + shared_lock(shared_lock&& __u) noexcept + : __m_(__u.__m_), + __owns_(__u.__owns_) + { + __u.__m_ = nullptr; + __u.__owns_ = false; + } + + _LIBCPP_INLINE_VISIBILITY + shared_lock& operator=(shared_lock&& __u) noexcept + { + if (__owns_) + __m_->unlock_shared(); + __m_ = nullptr; + __owns_ = false; + __m_ = __u.__m_; + __owns_ = __u.__owns_; + __u.__m_ = nullptr; + __u.__owns_ = false; + return *this; + } + + void lock(); + bool try_lock(); + template <class Rep, class Period> + bool try_lock_for(const chrono::duration<Rep, Period>& rel_time); + template <class Clock, class Duration> + bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time); + void unlock(); + + // Setters + _LIBCPP_INLINE_VISIBILITY + void swap(shared_lock& __u) noexcept + { + _VSTD::swap(__m_, __u.__m_); + _VSTD::swap(__owns_, __u.__owns_); + } + + _LIBCPP_INLINE_VISIBILITY + mutex_type* release() noexcept + { + mutex_type* __m = __m_; + __m_ = nullptr; + __owns_ = false; + return __m; + } + + // Getters + _LIBCPP_INLINE_VISIBILITY + bool owns_lock() const noexcept {return __owns_;} + + _LIBCPP_INLINE_VISIBILITY + explicit operator bool () const noexcept {return __owns_;} + + _LIBCPP_INLINE_VISIBILITY + mutex_type* mutex() const noexcept {return __m_;} +}; + +template <class _Mutex> +void +shared_lock<_Mutex>::lock() +{ + if (__m_ == nullptr) + __throw_system_error(EPERM, "shared_lock::lock: references null mutex"); + if (__owns_) + __throw_system_error(EDEADLK, "shared_lock::lock: already locked"); + __m_->lock_shared(); + __owns_ = true; +} + +template <class _Mutex> +bool +shared_lock<_Mutex>::try_lock() +{ + if (__m_ == nullptr) + __throw_system_error(EPERM, "shared_lock::try_lock: references null mutex"); + if (__owns_) + __throw_system_error(EDEADLK, "shared_lock::try_lock: already locked"); + __owns_ = __m_->try_lock_shared(); + return __owns_; +} + +template <class _Mutex> +template <class _Rep, class _Period> +bool +shared_lock<_Mutex>::try_lock_for(const chrono::duration<_Rep, _Period>& __d) +{ + if (__m_ == nullptr) + __throw_system_error(EPERM, "shared_lock::try_lock_for: references null mutex"); + if (__owns_) + __throw_system_error(EDEADLK, "shared_lock::try_lock_for: already locked"); + __owns_ = __m_->try_lock_shared_for(__d); + return __owns_; +} + +template <class _Mutex> +template <class _Clock, class _Duration> +bool +shared_lock<_Mutex>::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) +{ + if (__m_ == nullptr) + __throw_system_error(EPERM, "shared_lock::try_lock_until: references null mutex"); + if (__owns_) + __throw_system_error(EDEADLK, "shared_lock::try_lock_until: already locked"); + __owns_ = __m_->try_lock_shared_until(__t); + return __owns_; +} + +template <class _Mutex> +void +shared_lock<_Mutex>::unlock() +{ + if (!__owns_) + __throw_system_error(EPERM, "shared_lock::unlock: not locked"); + __m_->unlock_shared(); + __owns_ = false; +} + +template <class _Mutex> +inline _LIBCPP_INLINE_VISIBILITY +void +swap(shared_lock<_Mutex>& __x, shared_lock<_Mutex>& __y) noexcept + {__x.swap(__y);} + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP_STD_VER > 11 + +#endif // _LIBCPP_SHARED_MUTEX diff --git a/system/include/libcxx/sstream b/system/include/libcxx/sstream index a8f8148a..f90d4464 100644 --- a/system/include/libcxx/sstream +++ b/system/include/libcxx/sstream @@ -186,7 +186,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD // basic_stringbuf template <class _CharT, class _Traits, class _Allocator> -class _LIBCPP_TYPE_VIS basic_stringbuf +class _LIBCPP_TYPE_VIS_ONLY basic_stringbuf : public basic_streambuf<_CharT, _Traits> { public: @@ -613,7 +613,7 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::seekpos(pos_type __sp, // basic_istringstream template <class _CharT, class _Traits, class _Allocator> -class _LIBCPP_TYPE_VIS basic_istringstream +class _LIBCPP_TYPE_VIS_ONLY basic_istringstream : public basic_istream<_CharT, _Traits> { public: @@ -732,7 +732,7 @@ basic_istringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s) // basic_ostringstream template <class _CharT, class _Traits, class _Allocator> -class _LIBCPP_TYPE_VIS basic_ostringstream +class _LIBCPP_TYPE_VIS_ONLY basic_ostringstream : public basic_ostream<_CharT, _Traits> { public: @@ -851,7 +851,7 @@ basic_ostringstream<_CharT, _Traits, _Allocator>::str(const string_type& __s) // basic_stringstream template <class _CharT, class _Traits, class _Allocator> -class _LIBCPP_TYPE_VIS basic_stringstream +class _LIBCPP_TYPE_VIS_ONLY basic_stringstream : public basic_iostream<_CharT, _Traits> { public: diff --git a/system/include/libcxx/stack b/system/include/libcxx/stack index b8a7f4c0..30909c1e 100644 --- a/system/include/libcxx/stack +++ b/system/include/libcxx/stack @@ -91,7 +91,7 @@ template <class T, class Container> _LIBCPP_BEGIN_NAMESPACE_STD -template <class _Tp, class _Container> class _LIBCPP_TYPE_VIS stack; +template <class _Tp, class _Container> class _LIBCPP_TYPE_VIS_ONLY stack; template <class _Tp, class _Container> _LIBCPP_INLINE_VISIBILITY @@ -104,7 +104,7 @@ bool operator< (const stack<_Tp, _Container>& __x, const stack<_Tp, _Container>& __y); template <class _Tp, class _Container = deque<_Tp> > -class _LIBCPP_TYPE_VIS stack +class _LIBCPP_TYPE_VIS_ONLY stack { public: typedef _Container container_type; @@ -282,7 +282,7 @@ swap(stack<_Tp, _Container>& __x, stack<_Tp, _Container>& __y) } template <class _Tp, class _Container, class _Alloc> -struct _LIBCPP_TYPE_VIS uses_allocator<stack<_Tp, _Container>, _Alloc> +struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<stack<_Tp, _Container>, _Alloc> : public uses_allocator<_Container, _Alloc> { }; diff --git a/system/include/libcxx/streambuf b/system/include/libcxx/streambuf index 82615942..6adfc923 100644 --- a/system/include/libcxx/streambuf +++ b/system/include/libcxx/streambuf @@ -119,7 +119,7 @@ protected: _LIBCPP_BEGIN_NAMESPACE_STD template <class _CharT, class _Traits> -class _LIBCPP_TYPE_VIS basic_streambuf +class _LIBCPP_TYPE_VIS_ONLY basic_streambuf { public: // types: @@ -553,11 +553,11 @@ basic_streambuf<_CharT, _Traits>::overflow(int_type) return traits_type::eof(); } -_LIBCPP_EXTERN_TEMPLATE(class basic_streambuf<char>) -_LIBCPP_EXTERN_TEMPLATE(class basic_streambuf<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_streambuf<char>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_streambuf<wchar_t>) -_LIBCPP_EXTERN_TEMPLATE(class basic_ios<char>) -_LIBCPP_EXTERN_TEMPLATE(class basic_ios<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_ios<char>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_ios<wchar_t>) _LIBCPP_END_NAMESPACE_STD diff --git a/system/include/libcxx/string b/system/include/libcxx/string index 83dc53a1..e8bd69fc 100644 --- a/system/include/libcxx/string +++ b/system/include/libcxx/string @@ -447,7 +447,7 @@ basic_string<char32_t> operator "" s( const char32_t *str, size_t len ); // C++1 #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS #include <cstdint> #endif -#if defined(_LIBCPP_NO_EXCEPTIONS) || defined(_LIBCPP_DEBUG) +#if defined(_LIBCPP_NO_EXCEPTIONS) #include <cassert> #endif @@ -462,7 +462,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD // fpos template <class _StateT> -class _LIBCPP_TYPE_VIS fpos +class _LIBCPP_TYPE_VIS_ONLY fpos { private: _StateT __st_; @@ -499,7 +499,7 @@ bool operator!=(const fpos<_StateT>& __x, const fpos<_StateT>& __y) // char_traits template <class _CharT> -struct _LIBCPP_TYPE_VIS char_traits +struct _LIBCPP_TYPE_VIS_ONLY char_traits { typedef _CharT char_type; typedef int int_type; @@ -605,6 +605,7 @@ inline _LIBCPP_INLINE_VISIBILITY _CharT* char_traits<_CharT>::copy(char_type* __s1, const char_type* __s2, size_t __n) { + _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); char_type* __r = __s1; for (; __n; --__n, ++__s1, ++__s2) assign(*__s1, *__s2); @@ -625,7 +626,7 @@ char_traits<_CharT>::assign(char_type* __s, size_t __n, char_type __a) // char_traits<char> template <> -struct _LIBCPP_TYPE_VIS char_traits<char> +struct _LIBCPP_TYPE_VIS_ONLY char_traits<char> { typedef char char_type; typedef int int_type; @@ -656,7 +657,10 @@ struct _LIBCPP_TYPE_VIS char_traits<char> {return (char_type*)memmove(__s1, __s2, __n);} _LIBCPP_INLINE_VISIBILITY static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) - {return (char_type*)memcpy(__s1, __s2, __n);} + { + _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); + return (char_type*)memcpy(__s1, __s2, __n); + } _LIBCPP_INLINE_VISIBILITY static char_type* assign(char_type* __s, size_t __n, char_type __a) {return (char_type*)memset(__s, to_int_type(__a), __n);} @@ -681,7 +685,7 @@ struct _LIBCPP_TYPE_VIS char_traits<char> // char_traits<wchar_t> template <> -struct _LIBCPP_TYPE_VIS char_traits<wchar_t> +struct _LIBCPP_TYPE_VIS_ONLY char_traits<wchar_t> { typedef wchar_t char_type; typedef wint_t int_type; @@ -713,7 +717,10 @@ struct _LIBCPP_TYPE_VIS char_traits<wchar_t> {return (char_type*)wmemmove(__s1, __s2, __n);} _LIBCPP_INLINE_VISIBILITY static char_type* copy(char_type* __s1, const char_type* __s2, size_t __n) - {return (char_type*)wmemcpy(__s1, __s2, __n);} + { + _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); + return (char_type*)wmemcpy(__s1, __s2, __n); + } _LIBCPP_INLINE_VISIBILITY static char_type* assign(char_type* __s, size_t __n, char_type __a) {return (char_type*)wmemset(__s, __a, __n);} @@ -738,7 +745,7 @@ struct _LIBCPP_TYPE_VIS char_traits<wchar_t> #ifndef _LIBCPP_HAS_NO_UNICODE_CHARS template <> -struct _LIBCPP_TYPE_VIS char_traits<char16_t> +struct _LIBCPP_TYPE_VIS_ONLY char_traits<char16_t> { typedef char16_t char_type; typedef uint_least16_t int_type; @@ -841,6 +848,7 @@ inline _LIBCPP_INLINE_VISIBILITY char16_t* char_traits<char16_t>::copy(char_type* __s1, const char_type* __s2, size_t __n) { + _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); char_type* __r = __s1; for (; __n; --__n, ++__s1, ++__s2) assign(*__s1, *__s2); @@ -858,7 +866,7 @@ char_traits<char16_t>::assign(char_type* __s, size_t __n, char_type __a) } template <> -struct _LIBCPP_TYPE_VIS char_traits<char32_t> +struct _LIBCPP_TYPE_VIS_ONLY char_traits<char32_t> { typedef char32_t char_type; typedef uint_least32_t int_type; @@ -961,6 +969,7 @@ inline _LIBCPP_INLINE_VISIBILITY char32_t* char_traits<char32_t>::copy(char_type* __s1, const char_type* __s2, size_t __n) { + _LIBCPP_ASSERT(__s2 < __s1 || __s2 >= __s1+__n, "char_traits::copy overlapped range"); char_type* __r = __s1; for (; __n; --__n, ++__s1, ++__s2) assign(*__s1, *__s2); @@ -1003,7 +1012,7 @@ basic_string<_CharT, _Traits, _Allocator> operator+(const basic_string<_CharT, _Traits, _Allocator>& __x, _CharT __y); template <bool> -class __basic_string_common +class _LIBCPP_TYPE_VIS_ONLY __basic_string_common { protected: void __throw_length_error() const; @@ -1036,7 +1045,7 @@ __basic_string_common<__b>::__throw_out_of_range() const #pragma warning( push ) #pragma warning( disable: 4231 ) #endif // _LIBCPP_MSVC -_LIBCPP_EXTERN_TEMPLATE(class __basic_string_common<true>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS __basic_string_common<true>) #ifdef _LIBCPP_MSVC #pragma warning( pop ) #endif // _LIBCPP_MSVC @@ -1057,7 +1066,7 @@ struct __padding<_CharT, 1> #endif // _LIBCPP_ALTERNATE_STRING_LAYOUT template<class _CharT, class _Traits, class _Allocator> -class _LIBCPP_TYPE_VIS basic_string +class _LIBCPP_TYPE_VIS_ONLY basic_string : private __basic_string_common<true> { public: @@ -1072,13 +1081,13 @@ public: typedef const value_type& const_reference; typedef typename __alloc_traits::pointer pointer; typedef typename __alloc_traits::const_pointer const_pointer; -#ifdef _LIBCPP_DEBUG - typedef __debug_iter<basic_string, pointer> iterator; - typedef __debug_iter<basic_string, const_pointer> const_iterator; - friend class __debug_iter<basic_string, pointer>; - friend class __debug_iter<basic_string, const_pointer>; -#elif defined(_LIBCPP_RAW_ITERATORS) + static_assert(is_pod<value_type>::value, "Character type of basic_string must be a POD"); + static_assert((is_same<_CharT, value_type>::value), + "traits_type::char_type must be the same type as CharT"); + static_assert((is_same<typename allocator_type::value_type, value_type>::value), + "Allocator::value_type must be same type as value_type"); +#if defined(_LIBCPP_RAW_ITERATORS) typedef pointer iterator; typedef const_pointer const_iterator; #else // defined(_LIBCPP_RAW_ITERATORS) @@ -1152,9 +1161,9 @@ private: #endif // _LIBCPP_ALTERNATE_STRING_LAYOUT - union __lx{__long __lx; __short __lxx;}; + union __ulx{__long __lx; __short __lxx;}; - enum {__n_words = sizeof(__lx) / sizeof(size_type)}; + enum {__n_words = sizeof(__ulx) / sizeof(size_type)}; struct __raw { @@ -1173,15 +1182,6 @@ private: __compressed_pair<__rep, allocator_type> __r_; -#ifdef _LIBCPP_DEBUG - - pair<iterator*, const_iterator*> __iterator_list_; - - _LIBCPP_INLINE_VISIBILITY iterator*& __get_iterator_list(iterator*) {return __iterator_list_.first;} - _LIBCPP_INLINE_VISIBILITY const_iterator*& __get_iterator_list(const_iterator*) {return __iterator_list_.second;} - -#endif // _LIBCPP_DEBUG - public: static const size_type npos = -1; @@ -1239,7 +1239,20 @@ public: basic_string& operator=(initializer_list<value_type> __il) {return assign(__il.begin(), __il.size());} #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS -#ifndef _LIBCPP_DEBUG +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_INLINE_VISIBILITY + iterator begin() _NOEXCEPT + {return iterator(this, __get_pointer());} + _LIBCPP_INLINE_VISIBILITY + const_iterator begin() const _NOEXCEPT + {return const_iterator(this, __get_pointer());} + _LIBCPP_INLINE_VISIBILITY + iterator end() _NOEXCEPT + {return iterator(this, __get_pointer() + size());} + _LIBCPP_INLINE_VISIBILITY + const_iterator end() const _NOEXCEPT + {return const_iterator(this, __get_pointer() + size());} +#else _LIBCPP_INLINE_VISIBILITY iterator begin() _NOEXCEPT {return iterator(__get_pointer());} @@ -1252,12 +1265,7 @@ public: _LIBCPP_INLINE_VISIBILITY const_iterator end() const _NOEXCEPT {return const_iterator(__get_pointer() + size());} -#else // _LIBCPP_DEBUG - _LIBCPP_INLINE_VISIBILITY iterator begin() {return iterator(this, __get_pointer());} - _LIBCPP_INLINE_VISIBILITY const_iterator begin() const {return const_iterator(this, data());} - _LIBCPP_INLINE_VISIBILITY iterator end() {return iterator(this, __get_pointer() + size());} - _LIBCPP_INLINE_VISIBILITY const_iterator end() const {return const_iterator(this, data() + size());} -#endif // _LIBCPP_DEBUG +#endif // _LIBCPP_DEBUG_LEVEL >= 2 _LIBCPP_INLINE_VISIBILITY reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} @@ -1520,6 +1528,15 @@ public: bool __is_long() const _NOEXCEPT {return bool(__r_.first().__s.__size_ & __short_mask);} +#if _LIBCPP_DEBUG_LEVEL >= 2 + + bool __dereferenceable(const const_iterator* __i) const; + bool __decrementable(const const_iterator* __i) const; + bool __addable(const const_iterator* __i, ptrdiff_t __n) const; + bool __subscriptable(const const_iterator* __i, ptrdiff_t __n) const; + +#endif // _LIBCPP_DEBUG_LEVEL >= 2 + private: _LIBCPP_INLINE_VISIBILITY allocator_type& __alloc() _NOEXCEPT @@ -1615,13 +1632,13 @@ private: template <size_type __a> static _LIBCPP_INLINE_VISIBILITY - size_type __align(size_type __s) _NOEXCEPT + size_type __align_it(size_type __s) _NOEXCEPT {return __s + (__a-1) & ~(__a-1);} enum {__alignment = 16}; static _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __s) _NOEXCEPT {return (__s < __min_cap ? __min_cap : - __align<sizeof(value_type) < __alignment ? + __align_it<sizeof(value_type) < __alignment ? __alignment/sizeof(value_type) : 1 > (__s+1)) - 1;} void __init(const value_type* __s, size_type __sz, size_type __reserve); @@ -1732,75 +1749,64 @@ private: }; template <class _CharT, class _Traits, class _Allocator> -#ifndef _LIBCPP_DEBUG -_LIBCPP_INLINE_VISIBILITY inline -#endif +inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::__invalidate_all_iterators() { -#ifdef _LIBCPP_DEBUG - iterator::__remove_all(this); - const_iterator::__remove_all(this); -#endif // _LIBCPP_DEBUG +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__invalidate_all(this); +#endif // _LIBCPP_DEBUG_LEVEL >= 2 } template <class _CharT, class _Traits, class _Allocator> -#ifndef _LIBCPP_DEBUG -_LIBCPP_INLINE_VISIBILITY inline -#endif +inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::__invalidate_iterators_past(size_type -#ifdef _LIBCPP_DEBUG +#if _LIBCPP_DEBUG_LEVEL >= 2 __pos #endif ) { -#ifdef _LIBCPP_DEBUG - const_iterator __beg = begin(); - if (__iterator_list_.first) - { - for (iterator* __p = __iterator_list_.first; __p;) - { - if (*__p - __beg > static_cast<difference_type>(__pos)) - { - iterator* __n = __p; - __p = __p->__next; - __n->__remove_owner(); - } - else - __p = __p->__next; - } - } - if (__iterator_list_.second) +#if _LIBCPP_DEBUG_LEVEL >= 2 + __c_node* __c = __get_db()->__find_c_and_lock(this); + if (__c) { - for (const_iterator* __p = __iterator_list_.second; __p;) + const_pointer __new_last = __get_pointer() + __pos; + for (__i_node** __p = __c->end_; __p != __c->beg_; ) { - if (*__p - __beg > static_cast<difference_type>(__pos)) + --__p; + const_iterator* __i = static_cast<const_iterator*>((*__p)->__i_); + if (__i->base() > __new_last) { - const_iterator* __n = __p; - __p = __p->__next; - __n->__remove_owner(); + (*__p)->__c_ = nullptr; + if (--__c->end_ != __p) + memmove(__p, __p+1, (__c->end_ - __p)*sizeof(__i_node*)); } - else - __p = __p->__next; } + __get_db()->unlock(); } -#endif // _LIBCPP_DEBUG +#endif // _LIBCPP_DEBUG_LEVEL >= 2 } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __zero(); } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(const allocator_type& __a) : __r_(__a) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif __zero(); } @@ -1853,45 +1859,49 @@ basic_string<_CharT, _Traits, _Allocator>::__init(const value_type* __s, size_ty } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr"); __init(__s, traits_type::length(__s)); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s, const allocator_type& __a) : __r_(__a) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr"); __init(__s, traits_type::length(__s)); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s, size_type __n) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n) detected nullptr"); __init(__s, __n); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s, size_type __n, const allocator_type& __a) : __r_(__a) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detected nullptr"); __init(__s, __n); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template <class _CharT, class _Traits, class _Allocator> @@ -1902,6 +1912,9 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st __r_.first().__r = __str.__r_.first().__r; else __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size()); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template <class _CharT, class _Traits, class _Allocator> @@ -1912,24 +1925,29 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st __r_.first().__r = __str.__r_.first().__r; else __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size()); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str) _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) : __r_(_VSTD::move(__str.__r_)) { __str.__zero(); -#ifdef _LIBCPP_DEBUG - __str.__invalidate_all_iterators(); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); + if (__is_long()) + __get_db()->swap(this, &__str); #endif } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, const allocator_type& __a) : __r_(__a) { @@ -1938,8 +1956,10 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(basic_string&& __str, co else __init(_VSTD::__to_raw_pointer(__str.__get_long_pointer()), __str.__get_long_size()); __str.__zero(); -#ifdef _LIBCPP_DEBUG - __str.__invalidate_all_iterators(); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); + if (__is_long()) + __get_db()->swap(this, &__str); #endif } @@ -1970,18 +1990,24 @@ basic_string<_CharT, _Traits, _Allocator>::__init(size_type __n, value_type __c) } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, value_type __c) { __init(__n, __c); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(size_type __n, value_type __c, const allocator_type& __a) : __r_(__a) { __init(__n, __c); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template <class _CharT, class _Traits, class _Allocator> @@ -1993,6 +2019,9 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st if (__pos > __str_sz) this->__throw_out_of_range(); __init(__str.data() + __pos, _VSTD::min(__n, __str_sz - __pos)); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template <class _CharT, class _Traits, class _Allocator> @@ -2056,37 +2085,49 @@ basic_string<_CharT, _Traits, _Allocator>::__init(_ForwardIterator __first, _For template <class _CharT, class _Traits, class _Allocator> template<class _InputIterator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last) { __init(__first, __last); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template <class _CharT, class _Traits, class _Allocator> template<class _InputIterator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(_InputIterator __first, _InputIterator __last, const allocator_type& __a) : __r_(__a) { __init(__first, __last); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(initializer_list<value_type> __il) { __init(__il.begin(), __il.end()); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>::basic_string(initializer_list<value_type> __il, const allocator_type& __a) : __r_(__a) { __init(__il.begin(), __il.end()); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS @@ -2094,7 +2135,9 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(initializer_list<value_t template <class _CharT, class _Traits, class _Allocator> basic_string<_CharT, _Traits, _Allocator>::~basic_string() { - __invalidate_all_iterators(); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__erase_c(this); +#endif if (__is_long()) __alloc_traits::deallocate(__alloc(), __get_long_pointer(), __get_long_cap()); } @@ -2138,7 +2181,7 @@ basic_string<_CharT, _Traits, _Allocator>::__grow_by(size_type __old_cap, size_t size_type __n_copy, size_type __n_del, size_type __n_add) { size_type __ms = max_size(); - if (__delta_cap > __ms - __old_cap - 1) + if (__delta_cap > __ms - __old_cap) this->__throw_length_error(); pointer __old_p = __get_pointer(); size_type __cap = __old_cap < __ms / 2 - __alignment ? @@ -2166,9 +2209,7 @@ template <class _CharT, class _Traits, class _Allocator> basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s, size_type __n) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::assign recieved nullptr"); size_type __cap = capacity(); if (__cap >= __n) { @@ -2241,7 +2282,7 @@ basic_string<_CharT, _Traits, _Allocator>::operator=(const basic_string& __str) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, false_type) { @@ -2252,7 +2293,7 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, fa } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, true_type) _NOEXCEPT_(is_nothrow_move_assignable<allocator_type>::value) @@ -2265,7 +2306,7 @@ basic_string<_CharT, _Traits, _Allocator>::__move_assign(basic_string& __str, tr } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::operator=(basic_string&& __str) _NOEXCEPT_(__alloc_traits::propagate_on_container_move_assignment::value && @@ -2321,7 +2362,7 @@ basic_string<_CharT, _Traits, _Allocator>::assign(_ForwardIterator __first, _For } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::assign(const basic_string& __str) { @@ -2342,9 +2383,7 @@ template <class _CharT, class _Traits, class _Allocator> basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::assign(const value_type* __s) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::assign recieved nullptr"); return assign(__s, traits_type::length(__s)); } @@ -2354,9 +2393,7 @@ template <class _CharT, class _Traits, class _Allocator> basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s, size_type __n) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::append recieved nullptr"); size_type __cap = capacity(); size_type __sz = size(); if (__cap - __sz >= __n) @@ -2472,7 +2509,7 @@ basic_string<_CharT, _Traits, _Allocator>::append(_ForwardIterator __first, _For } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::append(const basic_string& __str) { @@ -2493,9 +2530,7 @@ template <class _CharT, class _Traits, class _Allocator> basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::append(const value_type* __s) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::append recieved nullptr"); return append(__s, traits_type::length(__s)); } @@ -2505,9 +2540,7 @@ template <class _CharT, class _Traits, class _Allocator> basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s, size_type __n) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::insert recieved nullptr"); size_type __sz = size(); if (__pos > __sz) this->__throw_out_of_range(); @@ -2576,13 +2609,22 @@ typename enable_if >::type basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _InputIterator __first, _InputIterator __last) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, + "string::insert(iterator, range) called with an iterator not" + " referring to this string"); +#endif size_type __old_sz = size(); difference_type __ip = __pos - begin(); for (; __first != __last; ++__first) push_back(*__first); pointer __p = __get_pointer(); _VSTD::rotate(__p + __ip, __p + __old_sz, __p + size()); +#if _LIBCPP_DEBUG_LEVEL >= 2 + return iterator(this, __p + __ip); +#else return iterator(__p + __ip); +#endif } template <class _CharT, class _Traits, class _Allocator> @@ -2594,6 +2636,11 @@ typename enable_if >::type basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _ForwardIterator __first, _ForwardIterator __last) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, + "string::insert(iterator, range) called with an iterator not" + " referring to this string"); +#endif size_type __ip = static_cast<size_type>(__pos - begin()); size_type __sz = size(); size_type __cap = capacity(); @@ -2623,7 +2670,7 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, _Forward } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos1, const basic_string& __str) { @@ -2645,9 +2692,7 @@ template <class _CharT, class _Traits, class _Allocator> basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::insert(size_type __pos, const value_type* __s) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::insert recieved nullptr"); return insert(__pos, __s, traits_type::length(__s)); } @@ -2678,10 +2723,15 @@ basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, value_ty } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::iterator basic_string<_CharT, _Traits, _Allocator>::insert(const_iterator __pos, size_type __n, value_type __c) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, + "string::insert(iterator, n, value) called with an iterator not" + " referring to this string"); +#endif difference_type __p = __pos - begin(); insert(static_cast<size_type>(__p), __n, __c); return begin() + __p; @@ -2693,9 +2743,7 @@ template <class _CharT, class _Traits, class _Allocator> basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s, size_type __n2) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::replace recieved nullptr"); size_type __sz = size(); if (__pos > __sz) this->__throw_out_of_range(); @@ -2805,7 +2853,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos1, size_type __n1, const basic_string& __str) { @@ -2827,14 +2875,12 @@ template <class _CharT, class _Traits, class _Allocator> basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(size_type __pos, size_type __n1, const value_type* __s) { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::replace recieved nullptr"); return replace(__pos, __n1, __s, traits_type::length(__s)); } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const basic_string& __str) { @@ -2843,7 +2889,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s, size_type __n) { @@ -2851,7 +2897,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, const value_type* __s) { @@ -2859,7 +2905,7 @@ basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_it } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator>& basic_string<_CharT, _Traits, _Allocator>::replace(const_iterator __i1, const_iterator __i2, size_type __n, value_type __c) { @@ -2891,10 +2937,17 @@ basic_string<_CharT, _Traits, _Allocator>::erase(size_type __pos, size_type __n) } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::iterator basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__pos) == this, + "string::erase(iterator) called with an iterator not" + " referring to this string"); +#endif + _LIBCPP_ASSERT(__pos != end(), + "string::erase(iterator) called with a non-dereferenceable iterator"); iterator __b = begin(); size_type __r = static_cast<size_type>(__pos - __b); erase(__r, 1); @@ -2902,10 +2955,16 @@ basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __pos) } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::iterator basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_iterator __last) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__first) == this, + "string::erase(iterator, iterator) called with an iterator not" + " referring to this string"); +#endif + _LIBCPP_ASSERT(__first <= __last, "string::erase(first, last) called with invalid range"); iterator __b = begin(); size_type __r = static_cast<size_type>(__first - __b); erase(__r, static_cast<size_type>(__last - __first)); @@ -2913,13 +2972,11 @@ basic_string<_CharT, _Traits, _Allocator>::erase(const_iterator __first, const_i } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::pop_back() { -#ifdef _LIBCPP_DEBUG - assert(!empty()); -#endif + _LIBCPP_ASSERT(!empty(), "string::pop_back(): string is already empty"); size_type __sz; if (__is_long()) { @@ -2937,7 +2994,7 @@ basic_string<_CharT, _Traits, _Allocator>::pop_back() } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT { @@ -2955,7 +3012,7 @@ basic_string<_CharT, _Traits, _Allocator>::clear() _NOEXCEPT } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::__erase_to_end(size_type __pos) { @@ -2984,15 +3041,15 @@ basic_string<_CharT, _Traits, _Allocator>::resize(size_type __n, value_type __c) } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::max_size() const _NOEXCEPT { size_type __m = __alloc_traits::max_size(__alloc()); #if _LIBCPP_BIG_ENDIAN - return (__m <= ~__long_mask ? __m : __m/2) - 1; + return (__m <= ~__long_mask ? __m : __m/2) - __alignment; #else - return __m - 1; + return __m - __alignment; #endif } @@ -3060,24 +3117,20 @@ basic_string<_CharT, _Traits, _Allocator>::reserve(size_type __res_arg) } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::const_reference basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) const { -#ifdef __LIBCPP_DEBUG - assert(__pos <= size()); -#endif + _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds"); return *(data() + __pos); } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::reference basic_string<_CharT, _Traits, _Allocator>::operator[](size_type __pos) { -#ifdef __LIBCPP_DEBUG - assert(__pos < size()); -#endif + _LIBCPP_ASSERT(__pos <= size(), "string index out of bounds"); return *(__get_pointer() + __pos); } @@ -3100,46 +3153,38 @@ basic_string<_CharT, _Traits, _Allocator>::at(size_type __n) } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::reference basic_string<_CharT, _Traits, _Allocator>::front() { -#ifdef _LIBCPP_DEBUG - assert(!empty()); -#endif + _LIBCPP_ASSERT(!empty(), "string::front(): string is empty"); return *__get_pointer(); } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::const_reference basic_string<_CharT, _Traits, _Allocator>::front() const { -#ifdef _LIBCPP_DEBUG - assert(!empty()); -#endif + _LIBCPP_ASSERT(!empty(), "string::front(): string is empty"); return *data(); } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::reference basic_string<_CharT, _Traits, _Allocator>::back() { -#ifdef _LIBCPP_DEBUG - assert(!empty()); -#endif + _LIBCPP_ASSERT(!empty(), "string::back(): string is empty"); return *(__get_pointer() + size() - 1); } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::const_reference basic_string<_CharT, _Traits, _Allocator>::back() const { -#ifdef _LIBCPP_DEBUG - assert(!empty()); -#endif + _LIBCPP_ASSERT(!empty(), "string::back(): string is empty"); return *(data() + size() - 1); } @@ -3156,7 +3201,7 @@ basic_string<_CharT, _Traits, _Allocator>::copy(value_type* __s, size_type __n, } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> basic_string<_CharT, _Traits, _Allocator>::substr(size_type __pos, size_type __n) const { @@ -3164,18 +3209,21 @@ basic_string<_CharT, _Traits, _Allocator>::substr(size_type __pos, size_type __n } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void basic_string<_CharT, _Traits, _Allocator>::swap(basic_string& __str) _NOEXCEPT_(!__alloc_traits::propagate_on_container_swap::value || __is_nothrow_swappable<allocator_type>::value) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + if (!__is_long()) + __get_db()->__invalidate_all(this); + if (!__str.__is_long()) + __get_db()->__invalidate_all(&__str); + __get_db()->swap(this, &__str); +#endif _VSTD::swap(__r_.first(), __str.__r_.first()); __swap_alloc(__alloc(), __str.__alloc()); -#ifdef _LIBCPP_DEBUG - __invalidate_all_iterators(); - __str.__invalidate_all_iterators(); -#endif // _LIBCPP_DEBUG } // find @@ -3195,9 +3243,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find(): recieved nullptr"); size_type __sz = size(); if (__pos > __sz || __sz - __pos < __n) return npos; @@ -3212,7 +3258,7 @@ basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str, size_type __pos) const _NOEXCEPT @@ -3221,14 +3267,12 @@ basic_string<_CharT, _Traits, _Allocator>::find(const basic_string& __str, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find(const value_type* __s, size_type __pos) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::find(): recieved nullptr"); return find(__s, __pos, traits_type::length(__s)); } @@ -3255,9 +3299,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::rfind(): recieved nullptr"); size_type __sz = size(); __pos = _VSTD::min(__pos, __sz); if (__n < __sz - __pos) @@ -3273,7 +3315,7 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str, size_type __pos) const _NOEXCEPT @@ -3282,14 +3324,12 @@ basic_string<_CharT, _Traits, _Allocator>::rfind(const basic_string& __str, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::rfind(const value_type* __s, size_type __pos) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::rfind(): recieved nullptr"); return rfind(__s, __pos, traits_type::length(__s)); } @@ -3323,9 +3363,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_of(): recieved nullptr"); size_type __sz = size(); if (__pos >= __sz || __n == 0) return npos; @@ -3338,7 +3376,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __str, size_type __pos) const _NOEXCEPT @@ -3347,19 +3385,17 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_of(const basic_string& __s } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_of(const value_type* __s, size_type __pos) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::find_first_of(): recieved nullptr"); return find_first_of(__s, __pos, traits_type::length(__s)); } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_of(value_type __c, size_type __pos) const _NOEXCEPT @@ -3375,9 +3411,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, size_type __pos, size_type __n) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_of(): recieved nullptr"); if (__n != 0) { size_type __sz = size(); @@ -3397,7 +3431,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __str, size_type __pos) const _NOEXCEPT @@ -3406,19 +3440,17 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_of(const basic_string& __st } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_of(const value_type* __s, size_type __pos) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::find_last_of(): recieved nullptr"); return find_last_of(__s, __pos, traits_type::length(__s)); } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_of(value_type __c, size_type __pos) const _NOEXCEPT @@ -3434,9 +3466,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* _ size_type __pos, size_type __n) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_first_not_of(): recieved nullptr"); size_type __sz = size(); if (__pos < __sz) { @@ -3450,7 +3480,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* _ } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& __str, size_type __pos) const _NOEXCEPT @@ -3459,19 +3489,17 @@ basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const basic_string& } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(const value_type* __s, size_type __pos) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::find_first_not_of(): recieved nullptr"); return find_first_not_of(__s, __pos, traits_type::length(__s)); } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_first_not_of(value_type __c, size_type __pos) const _NOEXCEPT @@ -3496,9 +3524,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __ size_type __pos, size_type __n) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "string::find_last_not_of(): recieved nullptr"); size_type __sz = size(); if (__pos < __sz) ++__pos; @@ -3512,7 +3538,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __ } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& __str, size_type __pos) const _NOEXCEPT @@ -3521,19 +3547,17 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const basic_string& } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(const value_type* __s, size_type __pos) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::find_last_not_of(): recieved nullptr"); return find_last_not_of(__s, __pos, traits_type::length(__s)); } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename basic_string<_CharT, _Traits, _Allocator>::size_type basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c, size_type __pos) const _NOEXCEPT @@ -3553,7 +3577,7 @@ basic_string<_CharT, _Traits, _Allocator>::find_last_not_of(value_type __c, // compare template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY int basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) const _NOEXCEPT { @@ -3571,7 +3595,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(const basic_string& __str) co } template <class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY int basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, @@ -3599,9 +3623,7 @@ template <class _CharT, class _Traits, class _Allocator> int basic_string<_CharT, _Traits, _Allocator>::compare(const value_type* __s) const _NOEXCEPT { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::compare(): recieved nullptr"); return compare(0, npos, __s, traits_type::length(__s)); } @@ -3611,9 +3633,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, size_type __n1, const value_type* __s) const { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__s != nullptr, "string::compare(): recieved nullptr"); return compare(__pos1, __n1, __s, traits_type::length(__s)); } @@ -3624,9 +3644,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, const value_type* __s, size_type __n2) const { -#ifdef _LIBCPP_DEBUG - assert(__s != 0); -#endif + _LIBCPP_ASSERT(__n2 == 0 || __s != nullptr, "string::compare(): recieved nullptr"); size_type __sz = size(); if (__pos1 > __sz || __n2 == npos) this->__throw_out_of_range(); @@ -3645,7 +3663,7 @@ basic_string<_CharT, _Traits, _Allocator>::compare(size_type __pos1, // __invariants template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool basic_string<_CharT, _Traits, _Allocator>::__invariants() const { @@ -3663,7 +3681,7 @@ basic_string<_CharT, _Traits, _Allocator>::__invariants() const // operator== template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3675,7 +3693,7 @@ operator==(const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template<class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs, const basic_string<char, char_traits<char>, _Allocator>& __rhs) _NOEXCEPT @@ -3694,7 +3712,7 @@ operator==(const basic_string<char, char_traits<char>, _Allocator>& __lhs, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator==(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3703,7 +3721,7 @@ operator==(const _CharT* __lhs, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT @@ -3714,7 +3732,7 @@ operator==(const basic_string<_CharT,_Traits,_Allocator>& __lhs, // operator!= template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3723,7 +3741,7 @@ operator!=(const basic_string<_CharT,_Traits,_Allocator>& __lhs, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3732,7 +3750,7 @@ operator!=(const _CharT* __lhs, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT @@ -3743,7 +3761,7 @@ operator!=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, // operator< template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3752,7 +3770,7 @@ operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT @@ -3761,7 +3779,7 @@ operator< (const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator< (const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3772,7 +3790,7 @@ operator< (const _CharT* __lhs, // operator> template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3781,7 +3799,7 @@ operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT @@ -3790,7 +3808,7 @@ operator> (const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator> (const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3801,7 +3819,7 @@ operator> (const _CharT* __lhs, // operator<= template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3810,7 +3828,7 @@ operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT @@ -3819,7 +3837,7 @@ operator<=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3830,7 +3848,7 @@ operator<=(const _CharT* __lhs, // operator>= template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3839,7 +3857,7 @@ operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) _NOEXCEPT @@ -3848,7 +3866,7 @@ operator>=(const basic_string<_CharT, _Traits, _Allocator>& __lhs, } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) _NOEXCEPT @@ -3920,7 +3938,7 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) { @@ -3928,7 +3946,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string< } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) { @@ -3936,7 +3954,7 @@ operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_ } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) { @@ -3944,7 +3962,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs) { @@ -3952,7 +3970,7 @@ operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs) } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs) { @@ -3961,7 +3979,7 @@ operator+(_CharT __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs) } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs) { @@ -3969,7 +3987,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs } template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) { @@ -3982,7 +4000,7 @@ operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, _CharT __rhs) // swap template<class _CharT, class _Traits, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void swap(basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>& __rhs) @@ -3998,45 +4016,45 @@ typedef basic_string<char32_t> u32string; #endif // _LIBCPP_HAS_NO_UNICODE_CHARS -int stoi (const string& __str, size_t* __idx = 0, int __base = 10); -long stol (const string& __str, size_t* __idx = 0, int __base = 10); -unsigned long stoul (const string& __str, size_t* __idx = 0, int __base = 10); -long long stoll (const string& __str, size_t* __idx = 0, int __base = 10); -unsigned long long stoull(const string& __str, size_t* __idx = 0, int __base = 10); - -float stof (const string& __str, size_t* __idx = 0); -double stod (const string& __str, size_t* __idx = 0); -long double stold(const string& __str, size_t* __idx = 0); - -string to_string(int __val); -string to_string(unsigned __val); -string to_string(long __val); -string to_string(unsigned long __val); -string to_string(long long __val); -string to_string(unsigned long long __val); -string to_string(float __val); -string to_string(double __val); -string to_string(long double __val); - -int stoi (const wstring& __str, size_t* __idx = 0, int __base = 10); -long stol (const wstring& __str, size_t* __idx = 0, int __base = 10); -unsigned long stoul (const wstring& __str, size_t* __idx = 0, int __base = 10); -long long stoll (const wstring& __str, size_t* __idx = 0, int __base = 10); -unsigned long long stoull(const wstring& __str, size_t* __idx = 0, int __base = 10); - -float stof (const wstring& __str, size_t* __idx = 0); -double stod (const wstring& __str, size_t* __idx = 0); -long double stold(const wstring& __str, size_t* __idx = 0); - -wstring to_wstring(int __val); -wstring to_wstring(unsigned __val); -wstring to_wstring(long __val); -wstring to_wstring(unsigned long __val); -wstring to_wstring(long long __val); -wstring to_wstring(unsigned long long __val); -wstring to_wstring(float __val); -wstring to_wstring(double __val); -wstring to_wstring(long double __val); +_LIBCPP_FUNC_VIS int stoi (const string& __str, size_t* __idx = 0, int __base = 10); +_LIBCPP_FUNC_VIS long stol (const string& __str, size_t* __idx = 0, int __base = 10); +_LIBCPP_FUNC_VIS unsigned long stoul (const string& __str, size_t* __idx = 0, int __base = 10); +_LIBCPP_FUNC_VIS long long stoll (const string& __str, size_t* __idx = 0, int __base = 10); +_LIBCPP_FUNC_VIS unsigned long long stoull(const string& __str, size_t* __idx = 0, int __base = 10); + +_LIBCPP_FUNC_VIS float stof (const string& __str, size_t* __idx = 0); +_LIBCPP_FUNC_VIS double stod (const string& __str, size_t* __idx = 0); +_LIBCPP_FUNC_VIS long double stold(const string& __str, size_t* __idx = 0); + +_LIBCPP_FUNC_VIS string to_string(int __val); +_LIBCPP_FUNC_VIS string to_string(unsigned __val); +_LIBCPP_FUNC_VIS string to_string(long __val); +_LIBCPP_FUNC_VIS string to_string(unsigned long __val); +_LIBCPP_FUNC_VIS string to_string(long long __val); +_LIBCPP_FUNC_VIS string to_string(unsigned long long __val); +_LIBCPP_FUNC_VIS string to_string(float __val); +_LIBCPP_FUNC_VIS string to_string(double __val); +_LIBCPP_FUNC_VIS string to_string(long double __val); + +_LIBCPP_FUNC_VIS int stoi (const wstring& __str, size_t* __idx = 0, int __base = 10); +_LIBCPP_FUNC_VIS long stol (const wstring& __str, size_t* __idx = 0, int __base = 10); +_LIBCPP_FUNC_VIS unsigned long stoul (const wstring& __str, size_t* __idx = 0, int __base = 10); +_LIBCPP_FUNC_VIS long long stoll (const wstring& __str, size_t* __idx = 0, int __base = 10); +_LIBCPP_FUNC_VIS unsigned long long stoull(const wstring& __str, size_t* __idx = 0, int __base = 10); + +_LIBCPP_FUNC_VIS float stof (const wstring& __str, size_t* __idx = 0); +_LIBCPP_FUNC_VIS double stod (const wstring& __str, size_t* __idx = 0); +_LIBCPP_FUNC_VIS long double stold(const wstring& __str, size_t* __idx = 0); + +_LIBCPP_FUNC_VIS wstring to_wstring(int __val); +_LIBCPP_FUNC_VIS wstring to_wstring(unsigned __val); +_LIBCPP_FUNC_VIS wstring to_wstring(long __val); +_LIBCPP_FUNC_VIS wstring to_wstring(unsigned long __val); +_LIBCPP_FUNC_VIS wstring to_wstring(long long __val); +_LIBCPP_FUNC_VIS wstring to_wstring(unsigned long long __val); +_LIBCPP_FUNC_VIS wstring to_wstring(float __val); +_LIBCPP_FUNC_VIS wstring to_wstring(double __val); +_LIBCPP_FUNC_VIS wstring to_wstring(long double __val); template<class _CharT, class _Traits, class _Allocator> const typename basic_string<_CharT, _Traits, _Allocator>::size_type @@ -4050,7 +4068,7 @@ size_t _LIBCPP_INLINE_VISIBILITY __do_string_hash(_Ptr __p, _Ptr __e) } template<class _CharT, class _Traits, class _Allocator> -struct _LIBCPP_TYPE_VIS hash<basic_string<_CharT, _Traits, _Allocator> > +struct _LIBCPP_TYPE_VIS_ONLY hash<basic_string<_CharT, _Traits, _Allocator> > : public unary_function<basic_string<_CharT, _Traits, _Allocator>, size_t> { size_t @@ -4102,12 +4120,45 @@ getline(basic_istream<_CharT, _Traits>&& __is, #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if _LIBCPP_DEBUG_LEVEL >= 2 + +template<class _CharT, class _Traits, class _Allocator> +bool +basic_string<_CharT, _Traits, _Allocator>::__dereferenceable(const const_iterator* __i) const +{ + return this->data() <= _VSTD::__to_raw_pointer(__i->base()) && + _VSTD::__to_raw_pointer(__i->base()) < this->data() + this->size(); +} + +template<class _CharT, class _Traits, class _Allocator> +bool +basic_string<_CharT, _Traits, _Allocator>::__decrementable(const const_iterator* __i) const +{ + return this->data() < _VSTD::__to_raw_pointer(__i->base()) && + _VSTD::__to_raw_pointer(__i->base()) <= this->data() + this->size(); +} + +template<class _CharT, class _Traits, class _Allocator> +bool +basic_string<_CharT, _Traits, _Allocator>::__addable(const const_iterator* __i, ptrdiff_t __n) const +{ + const value_type* __p = _VSTD::__to_raw_pointer(__i->base()) + __n; + return this->data() <= __p && __p <= this->data() + this->size(); +} + +template<class _CharT, class _Traits, class _Allocator> +bool +basic_string<_CharT, _Traits, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __n) const +{ + const value_type* __p = _VSTD::__to_raw_pointer(__i->base()) + __n; + return this->data() <= __p && __p < this->data() + this->size(); +} + +#endif // _LIBCPP_DEBUG_LEVEL >= 2 + #if _LIBCPP_STD_VER > 11 // Literal suffixes for basic_string [basic.string.literals] -// inline // Deviation from N3690. -// We believe the inline to be a defect and have submitted an LWG issue. -// An LWG issue number has not yet been assigned. -namespace literals +inline namespace literals { inline namespace string_literals { @@ -4138,12 +4189,9 @@ namespace literals } #endif -_LIBCPP_EXTERN_TEMPLATE(class basic_string<char>) -_LIBCPP_EXTERN_TEMPLATE(class basic_string<wchar_t>) - -extern template - string - operator+<char, char_traits<char>, allocator<char> >(char const*, string const&); +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_string<char>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS basic_string<wchar_t>) +_LIBCPP_EXTERN_TEMPLATE(string operator+<char, char_traits<char>, allocator<char> >(char const*, string const&)) _LIBCPP_END_NAMESPACE_STD diff --git a/system/include/libcxx/support/ibm/limits.h b/system/include/libcxx/support/ibm/limits.h new file mode 100644 index 00000000..efdb3596 --- /dev/null +++ b/system/include/libcxx/support/ibm/limits.h @@ -0,0 +1,99 @@ +// -*- C++ -*- +//===--------------------- support/ibm/limits.h ---------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_SUPPORT_IBM_LIMITS_H +#define _LIBCPP_SUPPORT_IBM_LIMITS_H + +#if !defined(_AIX) // Linux +#include <math.h> // for HUGE_VAL, HUGE_VALF, HUGE_VALL, and NAN + +static const unsigned int _QNAN_F = 0x7fc00000; +#define NANF (*((float *)(&_QNAN_F))) +static const unsigned int _QNAN_LDBL128[4] = {0x7ff80000, 0x0, 0x0, 0x0}; +#define NANL (*((long double *)(&_QNAN_LDBL128))) +static const unsigned int _SNAN_F= 0x7f855555; +#define NANSF (*((float *)(&_SNAN_F))) +static const unsigned int _SNAN_D[2] = {0x7ff55555, 0x55555555}; +#define NANS (*((double *)(&_SNAN_D))) +static const unsigned int _SNAN_LDBL128[4] = {0x7ff55555, 0x55555555, 0x0, 0x0}; +#define NANSL (*((long double *)(&_SNAN_LDBL128))) + +#define __builtin_huge_val() HUGE_VAL +#define __builtin_huge_valf() HUGE_VALF +#define __builtin_huge_vall() HUGE_VALL +#define __builtin_nan(__dummy) NAN +#define __builtin_nanf(__dummy) NANF +#define __builtin_nanl(__dummy) NANL +#define __builtin_nans(__dummy) NANS +#define __builtin_nansf(__dummy) NANSF +#define __builtin_nansl(__dummy) NANSL + +#else + +#include <math.h> +#include <float.h> // limit constants + +#define __builtin_huge_val() HUGE_VAL //0x7ff0000000000000 +#define __builtin_huge_valf() HUGE_VALF //0x7f800000 +#define __builtin_huge_vall() HUGE_VALL //0x7ff0000000000000 +#define __builtin_nan(__dummy) nan(__dummy) //0x7ff8000000000000 +#define __builtin_nanf(__dummy) nanf(__dummy) // 0x7ff80000 +#define __builtin_nanl(__dummy) nanl(__dummy) //0x7ff8000000000000 +#define __builtin_nans(__dummy) DBL_SNAN //0x7ff5555555555555 +#define __builtin_nansf(__dummy) FLT_SNAN //0x7f855555 +#define __builtin_nansl(__dummy) DBL_SNAN //0x7ff5555555555555 + +#define __FLT_MANT_DIG__ FLT_MANT_DIG +#define __FLT_DIG__ FLT_DIG +#define __FLT_RADIX__ FLT_RADIX +#define __FLT_MIN_EXP__ FLT_MIN_EXP +#define __FLT_MIN_10_EXP__ FLT_MIN_10_EXP +#define __FLT_MAX_EXP__ FLT_MAX_EXP +#define __FLT_MAX_10_EXP__ FLT_MAX_10_EXP +#define __FLT_MIN__ FLT_MIN +#define __FLT_MAX__ FLT_MAX +#define __FLT_EPSILON__ FLT_EPSILON +// predefined by XLC on LoP +#define __FLT_DENORM_MIN__ 1.40129846e-45F + +#define __DBL_MANT_DIG__ DBL_MANT_DIG +#define __DBL_DIG__ DBL_DIG +#define __DBL_MIN_EXP__ DBL_MIN_EXP +#define __DBL_MIN_10_EXP__ DBL_MIN_10_EXP +#define __DBL_MAX_EXP__ DBL_MAX_EXP +#define __DBL_MAX_10_EXP__ DBL_MAX_10_EXP +#define __DBL_MIN__ DBL_MIN +#define __DBL_MAX__ DBL_MAX +#define __DBL_EPSILON__ DBL_EPSILON +// predefined by XLC on LoP +#define __DBL_DENORM_MIN__ 4.9406564584124654e-324 + +#define __LDBL_MANT_DIG__ LDBL_MANT_DIG +#define __LDBL_DIG__ LDBL_DIG +#define __LDBL_MIN_EXP__ LDBL_MIN_EXP +#define __LDBL_MIN_10_EXP__ LDBL_MIN_10_EXP +#define __LDBL_MAX_EXP__ LDBL_MAX_EXP +#define __LDBL_MAX_10_EXP__ LDBL_MAX_10_EXP +#define __LDBL_MIN__ LDBL_MIN +#define __LDBL_MAX__ LDBL_MAX +#define __LDBL_EPSILON__ LDBL_EPSILON +// predefined by XLC on LoP +#if __LONGDOUBLE128 +#define __LDBL_DENORM_MIN__ 4.94065645841246544176568792868221e-324L +#else +#define __LDBL_DENORM_MIN__ 4.9406564584124654e-324L +#endif + +// predefined by XLC on LoP +#define __CHAR_BIT__ 8 + +#endif // _AIX + +#endif // _LIBCPP_SUPPORT_IBM_LIMITS_H diff --git a/system/include/libcxx/support/ibm/support.h b/system/include/libcxx/support/ibm/support.h new file mode 100644 index 00000000..3effbaed --- /dev/null +++ b/system/include/libcxx/support/ibm/support.h @@ -0,0 +1,54 @@ +// -*- C++ -*- +//===----------------------- support/ibm/support.h ----------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_SUPPORT_IBM_SUPPORT_H +#define _LIBCPP_SUPPORT_IBM_SUPPORT_H + +extern "builtin" int __popcnt4(unsigned int); +extern "builtin" int __popcnt8(unsigned long long); +extern "builtin" unsigned int __cnttz4(unsigned int); +extern "builtin" unsigned int __cnttz8(unsigned long long); +extern "builtin" unsigned int __cntlz4(unsigned long long); +extern "builtin" unsigned int __cntlz8(unsigned long long); + +// Builtin functions for counting population +#define __builtin_popcount(x) __popcnt4(x) +#define __builtin_popcountll(x) __popcnt8(x) +#if defined(__64BIT__) +#define __builtin_popcountl(x) __builtin_popcountll(x) +#else +#define __builtin_popcountl(x) __builtin_popcount(x) +#endif + +// Builtin functions for counting trailing zeros +#define __builtin_ctz(x) __cnttz4(x) +#define __builtin_ctzll(x) __cnttz8(x) +#if defined(__64BIT__) +#define __builtin_ctzl(x) __builtin_ctzll(x) +#else +#define __builtin_ctzl(x) __builtin_ctz(x) +#endif + +// Builtin functions for counting leading zeros +#define __builtin_clz(x) __cntlz4(x) +#define __builtin_clzll(x) __cntlz8(x) +#if defined(__64BIT__) +#define __builtin_clzl(x) __builtin_clzll(x) +#else +#define __builtin_clzl(x) __builtin_clz(x) +#endif + +#if defined(__64BIT__) +#define __SIZE_WIDTH__ 64 +#else +#define __SIZE_WIDTH__ 32 +#endif + +#endif // _LIBCPP_SUPPORT_IBM_SUPPORT_H diff --git a/system/include/libcxx/support/ibm/xlocale.h b/system/include/libcxx/support/ibm/xlocale.h new file mode 100644 index 00000000..8d99a5c7 --- /dev/null +++ b/system/include/libcxx/support/ibm/xlocale.h @@ -0,0 +1,326 @@ +// -*- C++ -*- +//===--------------------- support/ibm/xlocale.h -------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP_SUPPORT_IBM_XLOCALE_H +#define _LIBCPP_SUPPORT_IBM_XLOCALE_H + +#if defined(_AIX) +#include "cstdlib" + +#ifdef __cplusplus +extern "C" { +#endif + +#if !defined(_AIX71) +// AIX 7.1 and higher has these definitions. Definitions and stubs +// are provied here as a temporary workaround on AIX 6.1. + +#define LC_COLLATE_MASK 1 +#define LC_CTYPE_MASK 2 +#define LC_MESSAGES_MASK 4 +#define LC_MONETARY_MASK 8 +#define LC_NUMERIC_MASK 16 +#define LC_TIME_MASK 32 +#define LC_ALL_MASK (LC_COLLATE_MASK | LC_CTYPE_MASK | \ + LC_MESSAGES_MASK | LC_MONETARY_MASK |\ + LC_NUMERIC_MASK | LC_TIME_MASK) + +typedef void* locale_t; + +// The following are stubs. They are not supported on AIX 6.1. +static inline +locale_t newlocale(int category_mask, const char *locale, locale_t base) +{ + _LC_locale_t *newloc, *loc; + if ((loc = (_LC_locale_t *)__xopen_locale(locale)) == NULL) + { + errno = EINVAL; + return (locale_t)0; + } + if ((newloc = (_LC_locale_t *)calloc(1, sizeof(_LC_locale_t))) == NULL) + { + errno = ENOMEM; + return (locale_t)0; + } + if (!base) + base = (_LC_locale_t *)__xopen_locale("C"); + memcpy(newloc, base, sizeof (_LC_locale_t)); + if (category_mask & LC_COLLATE_MASK) + newloc->lc_collate = loc->lc_collate; + if (category_mask & LC_CTYPE_MASK) + newloc->lc_ctype = loc->lc_ctype; + //if (category_mask & LC_MESSAGES_MASK) + // newloc->lc_messages = loc->lc_messages; + if (category_mask & LC_MONETARY_MASK) + newloc->lc_monetary = loc->lc_monetary; + if (category_mask & LC_TIME_MASK) + newloc->lc_time = loc->lc_time; + if (category_mask & LC_NUMERIC_MASK) + newloc->lc_numeric = loc->lc_numeric; + return (locale_t)newloc; +} +static inline +void freelocale(locale_t locobj) +{ + free(locobj); +} +static inline +locale_t uselocale(locale_t newloc) +{ + return (locale_t)0; +} + +static inline +int isalnum_l(int c, locale_t locale) +{ + return __xisalnum(locale, c); +} +static inline +int isalpha_l(int c, locale_t locale) +{ + return __xisalpha(locale, c); +} +static inline +int isblank_l(int c, locale_t locale) +{ + return __xisblank(locale, c); +} +static inline +int iscntrl_l(int c, locale_t locale) +{ + return __xiscntrl(locale, c); +} +static inline +int isdigit_l(int c, locale_t locale) +{ + return __xisdigit(locale, c); +} +static inline +int isgraph_l(int c, locale_t locale) +{ + return __xisgraph(locale, c); +} +static inline +int islower_l(int c, locale_t locale) +{ + return __xislower(locale, c); +} +static inline +int isprint_l(int c, locale_t locale) +{ + return __xisprint(locale, c); +} + +static inline +int ispunct_l(int c, locale_t locale) +{ + return __xispunct(locale, c); +} +static inline +int isspace_l(int c, locale_t locale) +{ + return __xisspace(locale, c); +} +static inline +int isupper_l(int c, locale_t locale) +{ + return __xisupper(locale, c); +} + +static inline +int isxdigit_l(int c, locale_t locale) +{ + return __xisxdigit(locale, c); +} + +static inline +int iswalnum_l(wchar_t wc, locale_t locale) +{ + return __xiswalnum(locale, wc); +} + +static inline +int iswalpha_l(wchar_t wc, locale_t locale) +{ + return __xiswalpha(locale, wc); +} + +static inline +int iswblank_l(wchar_t wc, locale_t locale) +{ + return __xiswblank(locale, wc); +} + +static inline +int iswcntrl_l(wchar_t wc, locale_t locale) +{ + return __xiswcntrl(locale, wc); +} + +static inline +int iswdigit_l(wchar_t wc, locale_t locale) +{ + return __xiswdigit(locale, wc); +} + +static inline +int iswgraph_l(wchar_t wc, locale_t locale) +{ + return __xiswgraph(locale, wc); +} + +static inline +int iswlower_l(wchar_t wc, locale_t locale) +{ + return __xiswlower(locale, wc); +} + +static inline +int iswprint_l(wchar_t wc, locale_t locale) +{ + return __xiswprint(locale, wc); +} + +static inline +int iswpunct_l(wchar_t wc, locale_t locale) +{ + return __xiswpunct(locale, wc); +} + +static inline +int iswspace_l(wchar_t wc, locale_t locale) +{ + return __xiswspace(locale, wc); +} + +static inline +int iswupper_l(wchar_t wc, locale_t locale) +{ + return __xiswupper(locale, wc); +} + +static inline +int iswxdigit_l(wchar_t wc, locale_t locale) +{ + return __xiswxdigit(locale, wc); +} + +static inline +int iswctype_l(wint_t wc, wctype_t desc, locale_t locale) +{ + return __xiswctype(locale, wc, desc); +} + +static inline +int toupper_l(int c, locale_t locale) +{ + return __xtoupper(locale, c); +} +static inline +int tolower_l(int c, locale_t locale) +{ + return __xtolower(locale, c); +} +static inline +wint_t towupper_l(wint_t wc, locale_t locale) +{ + return __xtowupper(locale, wc); +} +static inline +wint_t towlower_l(wint_t wc, locale_t locale) +{ + return __xtowlower(locale, wc); +} + +static inline +int strcoll_l(const char *__s1, const char *__s2, locale_t locale) +{ + return __xstrcoll(locale, __s1, __s2); +} +static inline +int wcscoll_l(const wchar_t *__s1, const wchar_t *__s2, locale_t locale) +{ + return __xwcscoll(locale, __s1, __s2); +} +static inline +size_t strxfrm_l(char *__s1, const char *__s2, size_t __n, locale_t locale) +{ + return __xstrxfrm(locale, __s1, __s2, __n); +} + +static inline +size_t wcsxfrm_l(wchar_t *__ws1, const wchar_t *__ws2, size_t __n, + locale_t locale) +{ + return __xwcsxfrm(locale, __ws1, __ws2, __n); +} +#endif // !defined(_AIX71) + +// strftime_l() is defined by POSIX. However, AIX 7.1 does not have it +// implemented yet. +static inline +size_t strftime_l(char *__s, size_t __size, const char *__fmt, + const struct tm *__tm, locale_t locale) { + return __xstrftime(locale, __s, __size, __fmt, __tm); +} + +// The following are not POSIX routines. These are quick-and-dirty hacks +// to make things pretend to work +static inline +long long strtoll_l(const char *__nptr, char **__endptr, + int __base, locale_t locale) { + return strtoll(__nptr, __endptr, __base); +} +static inline +long strtol_l(const char *__nptr, char **__endptr, + int __base, locale_t locale) { + return strtol(__nptr, __endptr, __base); +} +static inline +long double strtold_l(const char *__nptr, char **__endptr, + locale_t locale) { + return strtold(__nptr, __endptr); +} +static inline +unsigned long long strtoull_l(const char *__nptr, char **__endptr, + int __base, locale_t locale) { + return strtoull(__nptr, __endptr, __base); +} +static inline +unsigned long strtoul_l(const char *__nptr, char **__endptr, + int __base, locale_t locale) { + return strtoul(__nptr, __endptr, __base); +} + +static inline +int vasprintf(char **strp, const char *fmt, va_list ap) +{ + const size_t buff_size = 256; + int str_size; + if ((*strp = (char *)malloc(buff_size)) == NULL) + { + return -1; + } + if ((str_size = vsnprintf(*strp, buff_size, fmt, ap)) >= buff_size) + { + if ((*strp = (char *)realloc(*strp, str_size + 1)) == NULL) + { + return -1; + } + str_size = vsnprintf(*strp, str_size + 1, fmt, ap); + } + return str_size; +} + +#ifdef __cplusplus +} +#endif +#endif // defined(_AIX) +#endif // _LIBCPP_SUPPORT_IBM_XLOCALE_H diff --git a/system/include/libcxx/support/win32/limits_win32.h b/system/include/libcxx/support/win32/limits_win32.h index 52229c4d..406cd302 100644 --- a/system/include/libcxx/support/win32/limits_win32.h +++ b/system/include/libcxx/support/win32/limits_win32.h @@ -12,16 +12,15 @@ #define _LIBCPP_SUPPORT_WIN32_LIMITS_WIN32_H #if !defined(_LIBCPP_MSVCRT) -#error "This header complements Microsoft's C Runtime library, and should not be included otherwise." +#error "This header complements the Microsoft C Runtime library, and should not be included otherwise." #else -#ifndef NOMINMAX -#define NOMINMAX -#endif -#include <windows.h> // ymath.h works correctly - +#include <limits.h> // CHAR_BIT #include <float.h> // limit constants +#if ! defined(__clang__) +#define __CHAR_BIT__ CHAR_BIT + #define __FLT_MANT_DIG__ FLT_MANT_DIG #define __FLT_DIG__ FLT_DIG #define __FLT_RADIX__ FLT_RADIX @@ -73,6 +72,7 @@ #define __builtin_nans(__dummy) _Snan._Double #define __builtin_nansf(__dummy) _FSnan._Float #define __builtin_nansl(__dummy) _LSnan._Long_double +#endif // ! defined(__clang__) #endif // _LIBCPP_MSVCRT diff --git a/system/include/libcxx/support/win32/locale_win32.h b/system/include/libcxx/support/win32/locale_win32.h index 019586c0..e768af50 100644 --- a/system/include/libcxx/support/win32/locale_win32.h +++ b/system/include/libcxx/support/win32/locale_win32.h @@ -15,6 +15,7 @@ extern "C" unsigned short __declspec(dllimport) _ctype[]; #include "support/win32/support.h" +#include <stdio.h> #include <memory> #include <xlocinfo.h> // _locale_t #define locale_t _locale_t @@ -35,23 +36,23 @@ extern "C" unsigned short __declspec(dllimport) _ctype[]; locale_t newlocale( int mask, const char * locale, locale_t base ); locale_t uselocale( locale_t newloc ); lconv *localeconv_l( locale_t loc ); -size_t mbrlen_l( const char *__restrict__ s, size_t n, - mbstate_t *__restrict__ ps, locale_t loc); -size_t mbsrtowcs_l( wchar_t *__restrict__ dst, const char **__restrict__ src, - size_t len, mbstate_t *__restrict__ ps, locale_t loc ); -size_t wcrtomb_l( char *__restrict__ s, wchar_t wc, mbstate_t *__restrict__ ps, +size_t mbrlen_l( const char *__restrict s, size_t n, + mbstate_t *__restrict ps, locale_t loc); +size_t mbsrtowcs_l( wchar_t *__restrict dst, const char **__restrict src, + size_t len, mbstate_t *__restrict ps, locale_t loc ); +size_t wcrtomb_l( char *__restrict s, wchar_t wc, mbstate_t *__restrict ps, locale_t loc); -size_t mbrtowc_l( wchar_t *__restrict__ pwc, const char *__restrict__ s, - size_t n, mbstate_t *__restrict__ ps, locale_t loc); -size_t mbsnrtowcs_l( wchar_t *__restrict__ dst, const char **__restrict__ src, - size_t nms, size_t len, mbstate_t *__restrict__ ps, locale_t loc); -size_t wcsnrtombs_l( char *__restrict__ dst, const wchar_t **__restrict__ src, - size_t nwc, size_t len, mbstate_t *__restrict__ ps, locale_t loc); +size_t mbrtowc_l( wchar_t *__restrict pwc, const char *__restrict s, + size_t n, mbstate_t *__restrict ps, locale_t loc); +size_t mbsnrtowcs_l( wchar_t *__restrict dst, const char **__restrict src, + size_t nms, size_t len, mbstate_t *__restrict ps, locale_t loc); +size_t wcsnrtombs_l( char *__restrict dst, const wchar_t **__restrict src, + size_t nwc, size_t len, mbstate_t *__restrict ps, locale_t loc); wint_t btowc_l( int c, locale_t loc ); int wctob_l( wint_t c, locale_t loc ); typedef _VSTD::remove_pointer<locale_t>::type __locale_struct; typedef _VSTD::unique_ptr<__locale_struct, decltype(&uselocale)> __locale_raii; -_LIBCPP_ALWAYS_INLINE inline +inline _LIBCPP_ALWAYS_INLINE decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l ) { __locale_raii __current( uselocale(__l), uselocale ); @@ -59,7 +60,6 @@ decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l ) } // the *_l functions are prefixed on Windows, only available for msvcr80+, VS2005+ -#include <stdio.h> #define mbtowc_l _mbtowc_l #define strtoll_l _strtoi64_l #define strtoull_l _strtoui64_l @@ -120,10 +120,10 @@ inline int iswblank_l( wint_t c, locale_t /*loc*/ ) return ( c == L' ' || c == L'\t' ); } -#ifdef _MSC_VER +#if defined(_LIBCPP_MSVCRT) inline int isblank( int c, locale_t /*loc*/ ) { return ( c == ' ' || c == '\t' ); } inline int iswblank( wint_t c, locale_t /*loc*/ ) { return ( c == L' ' || c == L'\t' ); } -#endif // _MSC_VER +#endif // _LIBCPP_MSVCRT #endif // _LIBCPP_SUPPORT_WIN32_LOCALE_WIN32_H diff --git a/system/include/libcxx/support/win32/math_win32.h b/system/include/libcxx/support/win32/math_win32.h index 22400c0d..c62c54e3 100644 --- a/system/include/libcxx/support/win32/math_win32.h +++ b/system/include/libcxx/support/win32/math_win32.h @@ -16,7 +16,9 @@ #else #include <math.h> +#include <float.h> // _FPCLASS_PN etc. +// Necessary? typedef float float_t; typedef double double_t; diff --git a/system/include/libcxx/support/win32/support.h b/system/include/libcxx/support/win32/support.h index 17abb915..b953ab77 100644 --- a/system/include/libcxx/support/win32/support.h +++ b/system/include/libcxx/support/win32/support.h @@ -15,11 +15,16 @@ Functions and constants used in libc++ that are missing from the Windows C library. */ -#include <cwchar> // mbstate_t +#include <wchar.h> // mbstate_t #include <cstdarg> // va_ macros #define swprintf _snwprintf #define vswprintf _vsnwprintf +#ifndef NOMINMAX +#define NOMINMAX +#endif +#include <Windows.h> + extern "C" { int vasprintf( char **sptr, const char *__restrict fmt, va_list ap ); diff --git a/system/include/libcxx/system_error b/system/include/libcxx/system_error index 1c1c7ebd..66bf6d6c 100644 --- a/system/include/libcxx/system_error +++ b/system/include/libcxx/system_error @@ -22,6 +22,7 @@ class error_category public: virtual ~error_category() noexcept; + constexpr error_category(); error_category(const error_category&) = delete; error_category& operator=(const error_category&) = delete; @@ -232,13 +233,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD // is_error_code_enum template <class _Tp> -struct _LIBCPP_TYPE_VIS is_error_code_enum +struct _LIBCPP_TYPE_VIS_ONLY is_error_code_enum : public false_type {}; // is_error_condition_enum template <class _Tp> -struct _LIBCPP_TYPE_VIS is_error_condition_enum +struct _LIBCPP_TYPE_VIS_ONLY is_error_condition_enum : public false_type {}; // Some error codes are not present on all platforms, so we provide equivalents @@ -345,12 +346,12 @@ _LIBCPP_DECLARE_STRONG_ENUM(errc) _LIBCPP_DECLARE_STRONG_ENUM_EPILOG(errc) template <> -struct _LIBCPP_TYPE_VIS is_error_condition_enum<errc> +struct _LIBCPP_TYPE_VIS_ONLY is_error_condition_enum<errc> : true_type { }; #ifdef _LIBCPP_HAS_NO_STRONG_ENUMS template <> -struct _LIBCPP_TYPE_VIS is_error_condition_enum<errc::__lx> +struct _LIBCPP_TYPE_VIS_ONLY is_error_condition_enum<errc::__lx> : true_type { }; #endif @@ -366,7 +367,12 @@ class _LIBCPP_TYPE_VIS error_category public: virtual ~error_category() _NOEXCEPT; +#ifdef _LIBCPP_BUILDING_SYSTEM_ERROR error_category() _NOEXCEPT; +#else + _LIBCPP_ALWAYS_INLINE + _LIBCPP_CONSTEXPR_AFTER_CXX11 error_category() _NOEXCEPT _LIBCPP_DEFAULT; +#endif private: error_category(const error_category&);// = delete; error_category& operator=(const error_category&);// = delete; @@ -397,8 +403,8 @@ public: virtual string message(int ev) const; }; -const error_category& generic_category() _NOEXCEPT; -const error_category& system_category() _NOEXCEPT; +_LIBCPP_FUNC_VIS const error_category& generic_category() _NOEXCEPT; +_LIBCPP_FUNC_VIS const error_category& system_category() _NOEXCEPT; class _LIBCPP_TYPE_VIS error_condition { @@ -597,7 +603,7 @@ operator!=(const error_condition& __x, const error_condition& __y) _NOEXCEPT {return !(__x == __y);} template <> -struct _LIBCPP_TYPE_VIS hash<error_code> +struct _LIBCPP_TYPE_VIS_ONLY hash<error_code> : public unary_function<error_code, size_t> { _LIBCPP_INLINE_VISIBILITY @@ -629,7 +635,7 @@ private: static string __init(const error_code&, string); }; -void __throw_system_error(int ev, const char* what_arg); +_LIBCPP_FUNC_VIS void __throw_system_error(int ev, const char* what_arg); _LIBCPP_END_NAMESPACE_STD diff --git a/system/include/libcxx/thread b/system/include/libcxx/thread index f41ea290..1f1e4a2b 100644 --- a/system/include/libcxx/thread +++ b/system/include/libcxx/thread @@ -185,10 +185,9 @@ _LIBCPP_INLINE_VISIBILITY __thread_id get_id() _NOEXCEPT; } // this_thread -class _LIBCPP_TYPE_VIS __thread_id; -template<> struct _LIBCPP_TYPE_VIS hash<__thread_id>; +template<> struct _LIBCPP_TYPE_VIS_ONLY hash<__thread_id>; -class _LIBCPP_TYPE_VIS __thread_id +class _LIBCPP_TYPE_VIS_ONLY __thread_id { // FIXME: pthread_t is a pointer on Darwin but a long on Linux. // NULL is the no-thread value on Darwin. Someone needs to check @@ -231,11 +230,11 @@ private: friend __thread_id this_thread::get_id() _NOEXCEPT; friend class _LIBCPP_TYPE_VIS thread; - friend struct _LIBCPP_TYPE_VIS hash<__thread_id>; + friend struct _LIBCPP_TYPE_VIS_ONLY hash<__thread_id>; }; template<> -struct _LIBCPP_TYPE_VIS hash<__thread_id> +struct _LIBCPP_TYPE_VIS_ONLY hash<__thread_id> : public unary_function<__thread_id, size_t> { _LIBCPP_INLINE_VISIBILITY @@ -307,7 +306,7 @@ class __assoc_sub_state; class _LIBCPP_HIDDEN __thread_struct_imp; -class __thread_struct +class _LIBCPP_TYPE_VIS __thread_struct { __thread_struct_imp* __p_; @@ -321,7 +320,7 @@ public: void __make_ready_at_thread_exit(__assoc_sub_state*); }; -__thread_specific_ptr<__thread_struct>& __thread_local_data(); +_LIBCPP_FUNC_VIS __thread_specific_ptr<__thread_struct>& __thread_local_data(); #ifndef _LIBCPP_HAS_NO_VARIADICS @@ -405,7 +404,7 @@ void swap(thread& __x, thread& __y) _NOEXCEPT {__x.swap(__y);} namespace this_thread { -void sleep_for(const chrono::nanoseconds& ns); +_LIBCPP_FUNC_VIS void sleep_for(const chrono::nanoseconds& ns); template <class _Rep, class _Period> void diff --git a/system/include/libcxx/tuple b/system/include/libcxx/tuple index 94876c91..a1a7bcf0 100644 --- a/system/include/libcxx/tuple +++ b/system/include/libcxx/tuple @@ -73,7 +73,7 @@ public: const unspecified ignore; template <class... T> tuple<V...> make_tuple(T&&...); // constexpr in C++14 -template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; +template <class... T> tuple<ATypes...> forward_as_tuple(T&&...) noexcept; // constexpr in C++14 template <class... T> tuple<T&...> tie(T&...) noexcept; template <class... Tuples> tuple<CTypes...> tuple_cat(Tuples&&... tpls); // constexpr in C++14 @@ -133,74 +133,12 @@ template <class... Types> _LIBCPP_BEGIN_NAMESPACE_STD -// allocator_arg_t - -struct _LIBCPP_TYPE_VIS allocator_arg_t { }; - -#if defined(_LIBCPP_HAS_NO_CONSTEXPR) || defined(_LIBCPP_BUILDING_MEMORY) -extern const allocator_arg_t allocator_arg; -#else -constexpr allocator_arg_t allocator_arg = allocator_arg_t(); -#endif - -// uses_allocator - -template <class _Tp> -struct __has_allocator_type -{ -private: - struct __two {char __lx; char __lxx;}; - template <class _Up> static __two __test(...); - template <class _Up> static char __test(typename _Up::allocator_type* = 0); -public: - static const bool value = sizeof(__test<_Tp>(0)) == 1; -}; - -template <class _Tp, class _Alloc, bool = __has_allocator_type<_Tp>::value> -struct __uses_allocator - : public integral_constant<bool, - is_convertible<_Alloc, typename _Tp::allocator_type>::value> -{ -}; - -template <class _Tp, class _Alloc> -struct __uses_allocator<_Tp, _Alloc, false> - : public false_type -{ -}; - -template <class _Tp, class _Alloc> -struct _LIBCPP_TYPE_VIS uses_allocator - : public __uses_allocator<_Tp, _Alloc> -{ -}; - -#ifndef _LIBCPP_HAS_NO_VARIADICS - -// uses-allocator construction - -template <class _Tp, class _Alloc, class ..._Args> -struct __uses_alloc_ctor_imp -{ - static const bool __ua = uses_allocator<_Tp, _Alloc>::value; - static const bool __ic = - is_constructible<_Tp, allocator_arg_t, _Alloc, _Args...>::value; - static const int value = __ua ? 2 - __ic : 0; -}; - -template <class _Tp, class _Alloc, class ..._Args> -struct __uses_alloc_ctor - : integral_constant<int, __uses_alloc_ctor_imp<_Tp, _Alloc, _Args...>::value> - {}; - -#endif // _LIBCPP_HAS_NO_VARIADICS - #ifndef _LIBCPP_HAS_NO_VARIADICS // tuple_size template <class ..._Tp> -class _LIBCPP_TYPE_VIS tuple_size<tuple<_Tp...> > +class _LIBCPP_TYPE_VIS_ONLY tuple_size<tuple<_Tp...> > : public integral_constant<size_t, sizeof...(_Tp)> { }; @@ -208,7 +146,7 @@ class _LIBCPP_TYPE_VIS tuple_size<tuple<_Tp...> > // tuple_element template <size_t _Ip, class ..._Tp> -class _LIBCPP_TYPE_VIS tuple_element<_Ip, tuple<_Tp...> > +class _LIBCPP_TYPE_VIS_ONLY tuple_element<_Ip, tuple<_Tp...> > { public: typedef typename tuple_element<_Ip, __tuple_types<_Tp...> >::type type; @@ -332,7 +270,7 @@ public: _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 __tuple_leaf(__tuple_leaf&& __t) _NOEXCEPT_(is_nothrow_move_constructible<_Hp>::value) - : value(_VSTD::move(__t.get())) + : value(_VSTD::forward<_Hp>(__t.get())) {} template <class _Tp> @@ -519,13 +457,24 @@ struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...> return *this; } - _LIBCPP_INLINE_VISIBILITY - __tuple_impl& - operator=(const __tuple_impl& __t) _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value)) - { - __swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t).get())...); - return *this; - } + __tuple_impl(const __tuple_impl&) = default; + __tuple_impl(__tuple_impl&&) = default; + + _LIBCPP_INLINE_VISIBILITY + __tuple_impl& + operator=(const __tuple_impl& __t) _NOEXCEPT_((__all<is_nothrow_copy_assignable<_Tp>::value...>::value)) + { + __swallow(__tuple_leaf<_Indx, _Tp>::operator=(static_cast<const __tuple_leaf<_Indx, _Tp>&>(__t).get())...); + return *this; + } + + _LIBCPP_INLINE_VISIBILITY + __tuple_impl& + operator=(__tuple_impl&& __t) _NOEXCEPT_((__all<is_nothrow_move_assignable<_Tp>::value...>::value)) + { + __swallow(__tuple_leaf<_Indx, _Tp>::operator=(_VSTD::forward<_Tp>(static_cast<__tuple_leaf<_Indx, _Tp>&>(__t).get()))...); + return *this; + } _LIBCPP_INLINE_VISIBILITY void swap(__tuple_impl& __t) @@ -536,7 +485,7 @@ struct __tuple_impl<__tuple_indices<_Indx...>, _Tp...> }; template <class ..._Tp> -class _LIBCPP_TYPE_VIS tuple +class _LIBCPP_TYPE_VIS_ONLY tuple { typedef __tuple_impl<typename __make_tuple_indices<sizeof...(_Tp)>::type, _Tp...> base; @@ -724,7 +673,7 @@ public: }; template <> -class _LIBCPP_TYPE_VIS tuple<> +class _LIBCPP_TYPE_VIS_ONLY tuple<> { public: _LIBCPP_INLINE_VISIBILITY @@ -810,7 +759,7 @@ struct __find_exactly_one_t_helper <_T1, _Idx, _Head, _Args...> { static constexpr size_t value = std::conditional< std::is_same<_T1, _Head>::value, - __find_exactly_one_t_checker<_T1, _Idx, Â Â _Args...>, + __find_exactly_one_t_checker<_T1, _Idx, _Args...>, __find_exactly_one_t_helper <_T1, _Idx+1, _Args...> >::type::value; }; @@ -864,7 +813,7 @@ struct __ignore_t namespace { const __ignore_t<unsigned char> ignore = __ignore_t<unsigned char>(); } -template <class _Tp> class _LIBCPP_TYPE_VIS reference_wrapper; +template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper; template <class _Tp> struct ___make_tuple_return @@ -895,14 +844,6 @@ make_tuple(_Tp&&... __t) template <class... _Tp> inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 tuple<_Tp&&...> -__forward_as_tuple(_Tp&&... __t) _NOEXCEPT -{ - return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...); -} - -template <class... _Tp> -inline _LIBCPP_INLINE_VISIBILITY -tuple<_Tp&&...> forward_as_tuple(_Tp&&... __t) _NOEXCEPT { return tuple<_Tp&&...>(_VSTD::forward<_Tp>(__t)...); @@ -1103,7 +1044,7 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J typename __tuple_cat_return_ref<tuple<_Types...>&&, _Tuple0&&>::type operator()(tuple<_Types...> __t, _Tuple0&& __t0) { - return __forward_as_tuple(_VSTD::forward<_Types>(get<_I0>(__t))..., + return forward_as_tuple(_VSTD::forward<_Types>(get<_I0>(__t))..., get<_J0>(_VSTD::forward<_Tuple0>(__t0))...); } @@ -1118,7 +1059,7 @@ struct __tuple_cat<tuple<_Types...>, __tuple_indices<_I0...>, __tuple_indices<_J tuple<_Types..., typename __apply_cv<_Tuple0, typename tuple_element<_J0, _T0>::type>::type&&...>, typename __make_tuple_indices<sizeof ...(_Types) + tuple_size<_T0>::value>::type, typename __make_tuple_indices<tuple_size<_T1>::value>::type>() - (__forward_as_tuple( + (forward_as_tuple( _VSTD::forward<_Types>(get<_I0>(__t))..., get<_J0>(_VSTD::forward<_Tuple0>(__t0))... ), @@ -1140,7 +1081,7 @@ tuple_cat(_Tuple0&& __t0, _Tuples&&... __tpls) } template <class ..._Tp, class _Alloc> -struct _LIBCPP_TYPE_VIS uses_allocator<tuple<_Tp...>, _Alloc> +struct _LIBCPP_TYPE_VIS_ONLY uses_allocator<tuple<_Tp...>, _Alloc> : true_type {}; template <class _T1, class _T2> diff --git a/system/include/libcxx/type_traits b/system/include/libcxx/type_traits index 99e34d13..b6430fbb 100644 --- a/system/include/libcxx/type_traits +++ b/system/include/libcxx/type_traits @@ -28,6 +28,7 @@ namespace std // Primary classification traits: template <class T> struct is_void; + template <class T> struct is_null_pointer; // C++14 template <class T> struct is_integral; template <class T> struct is_floating_point; template <class T> struct is_array; @@ -208,16 +209,16 @@ namespace std _LIBCPP_BEGIN_NAMESPACE_STD template <bool _Bp, class _If, class _Then> - struct _LIBCPP_TYPE_VIS conditional {typedef _If type;}; + struct _LIBCPP_TYPE_VIS_ONLY conditional {typedef _If type;}; template <class _If, class _Then> - struct _LIBCPP_TYPE_VIS conditional<false, _If, _Then> {typedef _Then type;}; + struct _LIBCPP_TYPE_VIS_ONLY conditional<false, _If, _Then> {typedef _Then type;}; #if _LIBCPP_STD_VER > 11 template <bool _Bp, class _If, class _Then> using conditional_t = typename conditional<_Bp, _If, _Then>::type; #endif -template <bool, class _Tp = void> struct _LIBCPP_TYPE_VIS enable_if {}; -template <class _Tp> struct _LIBCPP_TYPE_VIS enable_if<true, _Tp> {typedef _Tp type;}; +template <bool, class _Tp = void> struct _LIBCPP_TYPE_VIS_ONLY enable_if {}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY enable_if<true, _Tp> {typedef _Tp type;}; #if _LIBCPP_STD_VER > 11 template <bool _Bp, class _Tp = void> using enable_if_t = typename enable_if<_Bp, _Tp>::type; @@ -229,7 +230,7 @@ struct __two {char __lx[2];}; // helper class: template <class _Tp, _Tp __v> -struct _LIBCPP_TYPE_VIS integral_constant +struct _LIBCPP_TYPE_VIS_ONLY integral_constant { static _LIBCPP_CONSTEXPR const _Tp value = __v; typedef _Tp value_type; @@ -250,33 +251,33 @@ typedef integral_constant<bool, false> false_type; // is_const -template <class _Tp> struct _LIBCPP_TYPE_VIS is_const : public false_type {}; -template <class _Tp> struct _LIBCPP_TYPE_VIS is_const<_Tp const> : public true_type {}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const : public false_type {}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_const<_Tp const> : public true_type {}; // is_volatile -template <class _Tp> struct _LIBCPP_TYPE_VIS is_volatile : public false_type {}; -template <class _Tp> struct _LIBCPP_TYPE_VIS is_volatile<_Tp volatile> : public true_type {}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile : public false_type {}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_volatile<_Tp volatile> : public true_type {}; // remove_const -template <class _Tp> struct _LIBCPP_TYPE_VIS remove_const {typedef _Tp type;}; -template <class _Tp> struct _LIBCPP_TYPE_VIS remove_const<const _Tp> {typedef _Tp type;}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const {typedef _Tp type;}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_const<const _Tp> {typedef _Tp type;}; #if _LIBCPP_STD_VER > 11 template <class _Tp> using remove_const_t = typename remove_const<_Tp>::type; #endif // remove_volatile -template <class _Tp> struct _LIBCPP_TYPE_VIS remove_volatile {typedef _Tp type;}; -template <class _Tp> struct _LIBCPP_TYPE_VIS remove_volatile<volatile _Tp> {typedef _Tp type;}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile {typedef _Tp type;}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_volatile<volatile _Tp> {typedef _Tp type;}; #if _LIBCPP_STD_VER > 11 template <class _Tp> using remove_volatile_t = typename remove_volatile<_Tp>::type; #endif // remove_cv -template <class _Tp> struct _LIBCPP_TYPE_VIS remove_cv +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_cv {typedef typename remove_volatile<typename remove_const<_Tp>::type>::type type;}; #if _LIBCPP_STD_VER > 11 template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type; @@ -287,7 +288,7 @@ template <class _Tp> using remove_cv_t = typename remove_cv<_Tp>::type; template <class _Tp> struct __is_void : public false_type {}; template <> struct __is_void<void> : public true_type {}; -template <class _Tp> struct _LIBCPP_TYPE_VIS is_void +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_void : public __is_void<typename remove_cv<_Tp>::type> {}; // __is_nullptr_t @@ -295,9 +296,14 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS is_void template <class _Tp> struct ____is_nullptr_t : public false_type {}; template <> struct ____is_nullptr_t<nullptr_t> : public true_type {}; -template <class _Tp> struct _LIBCPP_TYPE_VIS __is_nullptr_t +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY __is_nullptr_t : public ____is_nullptr_t<typename remove_cv<_Tp>::type> {}; +#if _LIBCPP_STD_VER > 11 +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_null_pointer + : public ____is_nullptr_t<typename remove_cv<_Tp>::type> {}; +#endif + // is_integral template <class _Tp> struct __is_integral : public false_type {}; @@ -319,7 +325,7 @@ template <> struct __is_integral<unsigned long> : public true_type template <> struct __is_integral<long long> : public true_type {}; template <> struct __is_integral<unsigned long long> : public true_type {}; -template <class _Tp> struct _LIBCPP_TYPE_VIS is_integral +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_integral : public __is_integral<typename remove_cv<_Tp>::type> {}; // is_floating_point @@ -329,16 +335,16 @@ template <> struct __is_floating_point<float> : public true_type template <> struct __is_floating_point<double> : public true_type {}; template <> struct __is_floating_point<long double> : public true_type {}; -template <class _Tp> struct _LIBCPP_TYPE_VIS is_floating_point +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_floating_point : public __is_floating_point<typename remove_cv<_Tp>::type> {}; // is_array -template <class _Tp> struct _LIBCPP_TYPE_VIS is_array +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array : public false_type {}; -template <class _Tp> struct _LIBCPP_TYPE_VIS is_array<_Tp[]> +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[]> : public true_type {}; -template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS is_array<_Tp[_Np]> +template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY is_array<_Tp[_Np]> : public true_type {}; // is_pointer @@ -346,23 +352,23 @@ template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS is_array<_Tp[_Np]> template <class _Tp> struct __is_pointer : public false_type {}; template <class _Tp> struct __is_pointer<_Tp*> : public true_type {}; -template <class _Tp> struct _LIBCPP_TYPE_VIS is_pointer +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pointer : public __is_pointer<typename remove_cv<_Tp>::type> {}; // is_reference -template <class _Tp> struct _LIBCPP_TYPE_VIS is_lvalue_reference : public false_type {}; -template <class _Tp> struct _LIBCPP_TYPE_VIS is_lvalue_reference<_Tp&> : public true_type {}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference : public false_type {}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_lvalue_reference<_Tp&> : public true_type {}; -template <class _Tp> struct _LIBCPP_TYPE_VIS is_rvalue_reference : public false_type {}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference : public false_type {}; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -template <class _Tp> struct _LIBCPP_TYPE_VIS is_rvalue_reference<_Tp&&> : public true_type {}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_rvalue_reference<_Tp&&> : public true_type {}; #endif -template <class _Tp> struct _LIBCPP_TYPE_VIS is_reference : public false_type {}; -template <class _Tp> struct _LIBCPP_TYPE_VIS is_reference<_Tp&> : public true_type {}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference : public false_type {}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&> : public true_type {}; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -template <class _Tp> struct _LIBCPP_TYPE_VIS is_reference<_Tp&&> : public true_type {}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_reference<_Tp&&> : public true_type {}; #endif #if defined(__clang__) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) @@ -373,13 +379,13 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS is_reference<_Tp&&> : public true_t #if __has_feature(is_union) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) -template <class _Tp> struct _LIBCPP_TYPE_VIS is_union +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union : public integral_constant<bool, __is_union(_Tp)> {}; #else template <class _Tp> struct __libcpp_union : public false_type {}; -template <class _Tp> struct _LIBCPP_TYPE_VIS is_union +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_union : public __libcpp_union<typename remove_cv<_Tp>::type> {}; #endif @@ -388,7 +394,7 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS is_union #if __has_feature(is_class) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) -template <class _Tp> struct _LIBCPP_TYPE_VIS is_class +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class : public integral_constant<bool, __is_class(_Tp)> {}; #else @@ -399,15 +405,15 @@ template <class _Tp> char __test(int _Tp::*); template <class _Tp> __two __test(...); } -template <class _Tp> struct _LIBCPP_TYPE_VIS is_class +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_class : public integral_constant<bool, sizeof(__is_class_imp::__test<_Tp>(0)) == 1 && !is_union<_Tp>::value> {}; #endif // is_same -template <class _Tp, class _Up> struct _LIBCPP_TYPE_VIS is_same : public false_type {}; -template <class _Tp> struct _LIBCPP_TYPE_VIS is_same<_Tp, _Tp> : public true_type {}; +template <class _Tp, class _Up> struct _LIBCPP_TYPE_VIS_ONLY is_same : public false_type {}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_same<_Tp, _Tp> : public true_type {}; // is_function @@ -422,13 +428,13 @@ template <class _Tp, bool = is_class<_Tp>::value || is_union<_Tp>::value || is_void<_Tp>::value || is_reference<_Tp>::value || - is_same<_Tp, nullptr_t>::value > + __is_nullptr_t<_Tp>::value > struct __is_function : public integral_constant<bool, sizeof(__is_function_imp::__test<_Tp>(__is_function_imp::__source<_Tp>())) == 1> {}; template <class _Tp> struct __is_function<_Tp, true> : public false_type {}; -template <class _Tp> struct _LIBCPP_TYPE_VIS is_function +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_function : public __is_function<_Tp> {}; // is_member_function_pointer @@ -436,7 +442,7 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS is_function template <class _Tp> struct __is_member_function_pointer : public false_type {}; template <class _Tp, class _Up> struct __is_member_function_pointer<_Tp _Up::*> : public is_function<_Tp> {}; -template <class _Tp> struct _LIBCPP_TYPE_VIS is_member_function_pointer +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_function_pointer : public __is_member_function_pointer<typename remove_cv<_Tp>::type> {}; // is_member_pointer @@ -444,12 +450,12 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS is_member_function_pointer template <class _Tp> struct __is_member_pointer : public false_type {}; template <class _Tp, class _Up> struct __is_member_pointer<_Tp _Up::*> : public true_type {}; -template <class _Tp> struct _LIBCPP_TYPE_VIS is_member_pointer +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_pointer : public __is_member_pointer<typename remove_cv<_Tp>::type> {}; // is_member_object_pointer -template <class _Tp> struct _LIBCPP_TYPE_VIS is_member_object_pointer +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_member_object_pointer : public integral_constant<bool, is_member_pointer<_Tp>::value && !is_member_function_pointer<_Tp>::value> {}; @@ -457,12 +463,12 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS is_member_object_pointer #if __has_feature(is_enum) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) -template <class _Tp> struct _LIBCPP_TYPE_VIS is_enum +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum : public integral_constant<bool, __is_enum(_Tp)> {}; #else -template <class _Tp> struct _LIBCPP_TYPE_VIS is_enum +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_enum : public integral_constant<bool, !is_void<_Tp>::value && !is_integral<_Tp>::value && !is_floating_point<_Tp>::value && @@ -478,31 +484,31 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS is_enum // is_arithmetic -template <class _Tp> struct _LIBCPP_TYPE_VIS is_arithmetic +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_arithmetic : public integral_constant<bool, is_integral<_Tp>::value || is_floating_point<_Tp>::value> {}; // is_fundamental -template <class _Tp> struct _LIBCPP_TYPE_VIS is_fundamental +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_fundamental : public integral_constant<bool, is_void<_Tp>::value || __is_nullptr_t<_Tp>::value || is_arithmetic<_Tp>::value> {}; // is_scalar -template <class _Tp> struct _LIBCPP_TYPE_VIS is_scalar +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_scalar : public integral_constant<bool, is_arithmetic<_Tp>::value || is_member_pointer<_Tp>::value || is_pointer<_Tp>::value || __is_nullptr_t<_Tp>::value || is_enum<_Tp>::value > {}; -template <> struct _LIBCPP_TYPE_VIS is_scalar<nullptr_t> : public true_type {}; +template <> struct _LIBCPP_TYPE_VIS_ONLY is_scalar<nullptr_t> : public true_type {}; // is_object -template <class _Tp> struct _LIBCPP_TYPE_VIS is_object +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_object : public integral_constant<bool, is_scalar<_Tp>::value || is_array<_Tp>::value || is_union<_Tp>::value || @@ -510,7 +516,7 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS is_object // is_compound -template <class _Tp> struct _LIBCPP_TYPE_VIS is_compound +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_compound : public integral_constant<bool, !is_fundamental<_Tp>::value> {}; // add_const @@ -523,7 +529,7 @@ struct __add_const {typedef _Tp type;}; template <class _Tp> struct __add_const<_Tp, false> {typedef const _Tp type;}; -template <class _Tp> struct _LIBCPP_TYPE_VIS add_const +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_const {typedef typename __add_const<_Tp>::type type;}; #if _LIBCPP_STD_VER > 11 @@ -540,7 +546,7 @@ struct __add_volatile {typedef _Tp type;}; template <class _Tp> struct __add_volatile<_Tp, false> {typedef volatile _Tp type;}; -template <class _Tp> struct _LIBCPP_TYPE_VIS add_volatile +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_volatile {typedef typename __add_volatile<_Tp>::type type;}; #if _LIBCPP_STD_VER > 11 @@ -549,7 +555,7 @@ template <class _Tp> using add_volatile_t = typename add_volatile<_Tp>::type; // add_cv -template <class _Tp> struct _LIBCPP_TYPE_VIS add_cv +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_cv {typedef typename add_const<typename add_volatile<_Tp>::type>::type type;}; #if _LIBCPP_STD_VER > 11 @@ -558,10 +564,10 @@ template <class _Tp> using add_cv_t = typename add_cv<_Tp>::type; // remove_reference -template <class _Tp> struct _LIBCPP_TYPE_VIS remove_reference {typedef _Tp type;}; -template <class _Tp> struct _LIBCPP_TYPE_VIS remove_reference<_Tp&> {typedef _Tp type;}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference {typedef _Tp type;}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&> {typedef _Tp type;}; #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -template <class _Tp> struct _LIBCPP_TYPE_VIS remove_reference<_Tp&&> {typedef _Tp type;}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_reference<_Tp&&> {typedef _Tp type;}; #endif #if _LIBCPP_STD_VER > 11 @@ -570,12 +576,12 @@ template <class _Tp> using remove_reference_t = typename remove_reference<_Tp>:: // add_lvalue_reference -template <class _Tp> struct _LIBCPP_TYPE_VIS add_lvalue_reference {typedef _Tp& type;}; -template <class _Tp> struct _LIBCPP_TYPE_VIS add_lvalue_reference<_Tp&> {typedef _Tp& type;}; // for older compiler -template <> struct _LIBCPP_TYPE_VIS add_lvalue_reference<void> {typedef void type;}; -template <> struct _LIBCPP_TYPE_VIS add_lvalue_reference<const void> {typedef const void type;}; -template <> struct _LIBCPP_TYPE_VIS add_lvalue_reference<volatile void> {typedef volatile void type;}; -template <> struct _LIBCPP_TYPE_VIS add_lvalue_reference<const volatile void> {typedef const volatile void type;}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference {typedef _Tp& type;}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<_Tp&> {typedef _Tp& type;}; // for older compiler +template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<void> {typedef void type;}; +template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const void> {typedef const void type;}; +template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<volatile void> {typedef volatile void type;}; +template <> struct _LIBCPP_TYPE_VIS_ONLY add_lvalue_reference<const volatile void> {typedef const volatile void type;}; #if _LIBCPP_STD_VER > 11 template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_reference<_Tp>::type; @@ -583,11 +589,11 @@ template <class _Tp> using add_lvalue_reference_t = typename add_lvalue_referenc #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -template <class _Tp> struct _LIBCPP_TYPE_VIS add_rvalue_reference {typedef _Tp&& type;}; -template <> struct _LIBCPP_TYPE_VIS add_rvalue_reference<void> {typedef void type;}; -template <> struct _LIBCPP_TYPE_VIS add_rvalue_reference<const void> {typedef const void type;}; -template <> struct _LIBCPP_TYPE_VIS add_rvalue_reference<volatile void> {typedef volatile void type;}; -template <> struct _LIBCPP_TYPE_VIS add_rvalue_reference<const volatile void> {typedef const volatile void type;}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference {typedef _Tp&& type;}; +template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<void> {typedef void type;}; +template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const void> {typedef const void type;}; +template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<volatile void> {typedef volatile void type;}; +template <> struct _LIBCPP_TYPE_VIS_ONLY add_rvalue_reference<const volatile void> {typedef const volatile void type;}; #if _LIBCPP_STD_VER > 11 template <class _Tp> using add_rvalue_reference_t = typename add_rvalue_reference<_Tp>::type; @@ -616,11 +622,11 @@ struct __any // remove_pointer -template <class _Tp> struct _LIBCPP_TYPE_VIS remove_pointer {typedef _Tp type;}; -template <class _Tp> struct _LIBCPP_TYPE_VIS remove_pointer<_Tp*> {typedef _Tp type;}; -template <class _Tp> struct _LIBCPP_TYPE_VIS remove_pointer<_Tp* const> {typedef _Tp type;}; -template <class _Tp> struct _LIBCPP_TYPE_VIS remove_pointer<_Tp* volatile> {typedef _Tp type;}; -template <class _Tp> struct _LIBCPP_TYPE_VIS remove_pointer<_Tp* const volatile> {typedef _Tp type;}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer {typedef _Tp type;}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp*> {typedef _Tp type;}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const> {typedef _Tp type;}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* volatile> {typedef _Tp type;}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_pointer<_Tp* const volatile> {typedef _Tp type;}; #if _LIBCPP_STD_VER > 11 template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type; @@ -628,7 +634,7 @@ template <class _Tp> using remove_pointer_t = typename remove_pointer<_Tp>::type // add_pointer -template <class _Tp> struct _LIBCPP_TYPE_VIS add_pointer +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY add_pointer {typedef typename remove_reference<_Tp>::type* type;}; #if _LIBCPP_STD_VER > 11 @@ -648,7 +654,7 @@ struct __is_signed : public ___is_signed<_Tp> {}; template <class _Tp> struct __is_signed<_Tp, false> : public false_type {}; -template <class _Tp> struct _LIBCPP_TYPE_VIS is_signed : public __is_signed<_Tp> {}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_signed : public __is_signed<_Tp> {}; // is_unsigned @@ -663,37 +669,37 @@ struct __is_unsigned : public ___is_unsigned<_Tp> {}; template <class _Tp> struct __is_unsigned<_Tp, false> : public false_type {}; -template <class _Tp> struct _LIBCPP_TYPE_VIS is_unsigned : public __is_unsigned<_Tp> {}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_unsigned : public __is_unsigned<_Tp> {}; // rank -template <class _Tp> struct _LIBCPP_TYPE_VIS rank +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank : public integral_constant<size_t, 0> {}; -template <class _Tp> struct _LIBCPP_TYPE_VIS rank<_Tp[]> +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[]> : public integral_constant<size_t, rank<_Tp>::value + 1> {}; -template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS rank<_Tp[_Np]> +template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY rank<_Tp[_Np]> : public integral_constant<size_t, rank<_Tp>::value + 1> {}; // extent -template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TYPE_VIS extent +template <class _Tp, unsigned _Ip = 0> struct _LIBCPP_TYPE_VIS_ONLY extent : public integral_constant<size_t, 0> {}; -template <class _Tp> struct _LIBCPP_TYPE_VIS extent<_Tp[], 0> +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], 0> : public integral_constant<size_t, 0> {}; -template <class _Tp, unsigned _Ip> struct _LIBCPP_TYPE_VIS extent<_Tp[], _Ip> +template <class _Tp, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[], _Ip> : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {}; -template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS extent<_Tp[_Np], 0> +template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], 0> : public integral_constant<size_t, _Np> {}; -template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TYPE_VIS extent<_Tp[_Np], _Ip> +template <class _Tp, size_t _Np, unsigned _Ip> struct _LIBCPP_TYPE_VIS_ONLY extent<_Tp[_Np], _Ip> : public integral_constant<size_t, extent<_Tp, _Ip-1>::value> {}; // remove_extent -template <class _Tp> struct _LIBCPP_TYPE_VIS remove_extent +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent {typedef _Tp type;}; -template <class _Tp> struct _LIBCPP_TYPE_VIS remove_extent<_Tp[]> +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[]> {typedef _Tp type;}; -template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS remove_extent<_Tp[_Np]> +template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_extent<_Tp[_Np]> {typedef _Tp type;}; #if _LIBCPP_STD_VER > 11 @@ -702,17 +708,42 @@ template <class _Tp> using remove_extent_t = typename remove_extent<_Tp>::type; // remove_all_extents -template <class _Tp> struct _LIBCPP_TYPE_VIS remove_all_extents +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents {typedef _Tp type;}; -template <class _Tp> struct _LIBCPP_TYPE_VIS remove_all_extents<_Tp[]> +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[]> {typedef typename remove_all_extents<_Tp>::type type;}; -template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS remove_all_extents<_Tp[_Np]> +template <class _Tp, size_t _Np> struct _LIBCPP_TYPE_VIS_ONLY remove_all_extents<_Tp[_Np]> {typedef typename remove_all_extents<_Tp>::type type;}; #if _LIBCPP_STD_VER > 11 template <class _Tp> using remove_all_extents_t = typename remove_all_extents<_Tp>::type; #endif +// decay + +template <class _Tp> +struct _LIBCPP_TYPE_VIS_ONLY decay +{ +private: + typedef typename remove_reference<_Tp>::type _Up; +public: + typedef typename conditional + < + is_array<_Up>::value, + typename remove_extent<_Up>::type*, + typename conditional + < + is_function<_Up>::value, + typename add_pointer<_Up>::type, + typename remove_cv<_Up>::type + >::type + >::type type; +}; + +#if _LIBCPP_STD_VER > 11 +template <class _Tp> using decay_t = typename decay<_Tp>::type; +#endif + // is_abstract namespace __is_abstract_imp @@ -726,14 +757,14 @@ struct __libcpp_abstract : public integral_constant<bool, sizeof(__is_abstract_i template <class _Tp> struct __libcpp_abstract<_Tp, false> : public false_type {}; -template <class _Tp> struct _LIBCPP_TYPE_VIS is_abstract : public __libcpp_abstract<_Tp> {}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_abstract : public __libcpp_abstract<_Tp> {}; // is_base_of #ifdef _LIBCPP_HAS_IS_BASE_OF template <class _Bp, class _Dp> -struct _LIBCPP_TYPE_VIS is_base_of +struct _LIBCPP_TYPE_VIS_ONLY is_base_of : public integral_constant<bool, __is_base_of(_Bp, _Dp)> {}; #else // __has_feature(is_base_of) @@ -757,7 +788,7 @@ template <class _Bp, class _Dp> __two __test(...); } template <class _Bp, class _Dp> -struct _LIBCPP_TYPE_VIS is_base_of +struct _LIBCPP_TYPE_VIS_ONLY is_base_of : public integral_constant<bool, is_class<_Bp>::value && sizeof(__is_base_of_imp::__test<_Bp, _Dp>(0)) == 2> {}; @@ -767,7 +798,7 @@ struct _LIBCPP_TYPE_VIS is_base_of #if __has_feature(is_convertible_to) -template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS is_convertible +template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible : public integral_constant<bool, __is_convertible_to(_T1, _T2) && !is_abstract<_T2>::value> {}; @@ -873,7 +904,7 @@ template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 1, 3> : public template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 2, 3> : public false_type {}; template <class _T1, class _T2> struct __is_convertible<_T1, _T2, 3, 3> : public true_type {}; -template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS is_convertible +template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS_ONLY is_convertible : public __is_convertible<_T1, _T2> { static const size_t __complete_check1 = __is_convertible_check<_T1>::__v; @@ -887,7 +918,7 @@ template <class _T1, class _T2> struct _LIBCPP_TYPE_VIS is_convertible #if __has_feature(is_empty) template <class _Tp> -struct _LIBCPP_TYPE_VIS is_empty +struct _LIBCPP_TYPE_VIS_ONLY is_empty : public integral_constant<bool, __is_empty(_Tp)> {}; #else // __has_feature(is_empty) @@ -909,7 +940,7 @@ struct __libcpp_empty : public integral_constant<bool, sizeof(__is_empty1<_Tp>) template <class _Tp> struct __libcpp_empty<_Tp, false> : public false_type {}; -template <class _Tp> struct _LIBCPP_TYPE_VIS is_empty : public __libcpp_empty<_Tp> {}; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_empty : public __libcpp_empty<_Tp> {}; #endif // __has_feature(is_empty) @@ -918,7 +949,7 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS is_empty : public __libcpp_empty<_T #if __has_feature(is_polymorphic) template <class _Tp> -struct _LIBCPP_TYPE_VIS is_polymorphic +struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic : public integral_constant<bool, __is_polymorphic(_Tp)> {}; #else @@ -928,7 +959,7 @@ template<typename _Tp> char &__is_polymorphic_impl( int>::type); template<typename _Tp> __two &__is_polymorphic_impl(...); -template <class _Tp> struct _LIBCPP_TYPE_VIS is_polymorphic +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_polymorphic : public integral_constant<bool, sizeof(__is_polymorphic_impl<_Tp>(0)) == 1> {}; #endif // __has_feature(is_polymorphic) @@ -937,19 +968,19 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS is_polymorphic #if __has_feature(has_virtual_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) -template <class _Tp> struct _LIBCPP_TYPE_VIS has_virtual_destructor +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor : public integral_constant<bool, __has_virtual_destructor(_Tp)> {}; #else // _LIBCPP_HAS_TYPE_TRAITS -template <class _Tp> struct _LIBCPP_TYPE_VIS has_virtual_destructor +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY has_virtual_destructor : public false_type {}; #endif // _LIBCPP_HAS_TYPE_TRAITS // alignment_of -template <class _Tp> struct _LIBCPP_TYPE_VIS alignment_of +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY alignment_of : public integral_constant<size_t, __alignof__(_Tp)> {}; // aligned_storage @@ -1037,7 +1068,7 @@ struct __find_max_align<__type_list<_Hp, _Tp>, _Len> : public integral_constant<size_t, __select_align<_Len, _Hp::value, __find_max_align<_Tp, _Len>::value>::value> {}; template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::value> -struct _LIBCPP_TYPE_VIS aligned_storage +struct _LIBCPP_TYPE_VIS_ONLY aligned_storage { typedef typename __find_pod<__all_types, _Align>::type _Aligner; static_assert(!is_void<_Aligner>::value, ""); @@ -1055,7 +1086,7 @@ template <size_t _Len, size_t _Align = __find_max_align<__all_types, _Len>::valu #define _CREATE_ALIGNED_STORAGE_SPECIALIZATION(n) \ template <size_t _Len>\ -struct _LIBCPP_TYPE_VIS aligned_storage<_Len, n>\ +struct _LIBCPP_TYPE_VIS_ONLY aligned_storage<_Len, n>\ {\ struct _ALIGNAS(n) type\ {\ @@ -1274,7 +1305,7 @@ template <> struct __make_signed< signed long long, true> {typedef long long ty template <> struct __make_signed<unsigned long long, true> {typedef long long type;}; template <class _Tp> -struct _LIBCPP_TYPE_VIS make_signed +struct _LIBCPP_TYPE_VIS_ONLY make_signed { typedef typename __apply_cv<_Tp, typename __make_signed<typename remove_cv<_Tp>::type>::type>::type type; }; @@ -1303,7 +1334,7 @@ template <> struct __make_unsigned< signed long long, true> {typedef unsigned l template <> struct __make_unsigned<unsigned long long, true> {typedef unsigned long long type;}; template <class _Tp> -struct _LIBCPP_TYPE_VIS make_unsigned +struct _LIBCPP_TYPE_VIS_ONLY make_unsigned { typedef typename __apply_cv<_Tp, typename __make_unsigned<typename remove_cv<_Tp>::type>::type>::type type; }; @@ -1315,21 +1346,21 @@ template <class _Tp> using make_unsigned_t = typename make_unsigned<_Tp>::type; #ifdef _LIBCPP_HAS_NO_VARIADICS template <class _Tp, class _Up = void, class V = void> -struct _LIBCPP_TYPE_VIS common_type +struct _LIBCPP_TYPE_VIS_ONLY common_type { public: typedef typename common_type<typename common_type<_Tp, _Up>::type, V>::type type; }; template <class _Tp> -struct _LIBCPP_TYPE_VIS common_type<_Tp, void, void> +struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, void, void> { public: typedef _Tp type; }; template <class _Tp, class _Up> -struct _LIBCPP_TYPE_VIS common_type<_Tp, _Up, void> +struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, void> { private: #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -1348,24 +1379,24 @@ public: template <class ..._Tp> struct common_type; template <class _Tp> -struct _LIBCPP_TYPE_VIS common_type<_Tp> +struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp> { - typedef _Tp type; + typedef typename decay<_Tp>::type type; }; template <class _Tp, class _Up> -struct _LIBCPP_TYPE_VIS common_type<_Tp, _Up> +struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up> { private: static _Tp&& __t(); static _Up&& __u(); static bool __f(); public: - typedef typename remove_reference<decltype(__f() ? __t() : __u())>::type type; + typedef typename decay<decltype(__f() ? __t() : __u())>::type type; }; template <class _Tp, class _Up, class ..._Vp> -struct _LIBCPP_TYPE_VIS common_type<_Tp, _Up, _Vp...> +struct _LIBCPP_TYPE_VIS_ONLY common_type<_Tp, _Up, _Vp...> { typedef typename common_type<typename common_type<_Tp, _Up>::type, _Vp...>::type type; }; @@ -1378,8 +1409,10 @@ template <class ..._Tp> using common_type_t = typename common_type<_Tp...>::type // is_assignable +template<typename, typename T> struct __select_2nd { typedef T type; }; + template <class _Tp, class _Arg> -decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>(), true_type())) +typename __select_2nd<decltype((_VSTD::declval<_Tp>() = _VSTD::declval<_Arg>())), true_type>::type #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES __is_assignable_test(_Tp&&, _Arg&&); #else @@ -1413,13 +1446,13 @@ struct is_assignable // is_copy_assignable -template <class _Tp> struct _LIBCPP_TYPE_VIS is_copy_assignable +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_copy_assignable : public is_assignable<typename add_lvalue_reference<_Tp>::type, const typename add_lvalue_reference<_Tp>::type> {}; // is_move_assignable -template <class _Tp> struct _LIBCPP_TYPE_VIS is_move_assignable +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_move_assignable #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES : public is_assignable<typename add_lvalue_reference<_Tp>::type, const typename add_rvalue_reference<_Tp>::type> {}; @@ -1446,7 +1479,8 @@ __is_destructible_test(_Tp&); false_type __is_destructible_test(__any); -template <class _Tp, bool = is_void<_Tp>::value || is_abstract<_Tp>::value> +template <class _Tp, bool = is_void<_Tp>::value || is_abstract<_Tp>::value + || is_function<_Tp>::value> struct __destructible_imp : public common_type < @@ -1461,6 +1495,10 @@ template <class _Tp> struct is_destructible : public __destructible_imp<_Tp> {}; +template <class _Tp> +struct is_destructible<_Tp[]> + : public false_type {}; + // move #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -1533,29 +1571,6 @@ public: #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -template <class _Tp> -struct _LIBCPP_TYPE_VIS decay -{ -private: - typedef typename remove_reference<_Tp>::type _Up; -public: - typedef typename conditional - < - is_array<_Up>::value, - typename remove_extent<_Up>::type*, - typename conditional - < - is_function<_Up>::value, - typename add_pointer<_Up>::type, - typename remove_cv<_Up>::type - >::type - >::type type; -}; - -#if _LIBCPP_STD_VER > 11 -template <class _Tp> using decay_t = typename decay<_Tp>::type; -#endif - #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class _Tp> @@ -1917,7 +1932,7 @@ class __result_of<_Fn(_Tp, _A0, _A1, _A2), false, true> // _Fn must be member p // result_of template <class _Fn> -class _LIBCPP_TYPE_VIS result_of<_Fn()> +class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn()> : public __result_of<_Fn(), is_class<typename remove_reference<_Fn>::type>::value || is_function<typename remove_reference<_Fn>::type>::value, @@ -1927,7 +1942,7 @@ class _LIBCPP_TYPE_VIS result_of<_Fn()> }; template <class _Fn, class _A0> -class _LIBCPP_TYPE_VIS result_of<_Fn(_A0)> +class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0)> : public __result_of<_Fn(_A0), is_class<typename remove_reference<_Fn>::type>::value || is_function<typename remove_reference<_Fn>::type>::value, @@ -1937,7 +1952,7 @@ class _LIBCPP_TYPE_VIS result_of<_Fn(_A0)> }; template <class _Fn, class _A0, class _A1> -class _LIBCPP_TYPE_VIS result_of<_Fn(_A0, _A1)> +class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1)> : public __result_of<_Fn(_A0, _A1), is_class<typename remove_reference<_Fn>::type>::value || is_function<typename remove_reference<_Fn>::type>::value, @@ -1947,7 +1962,7 @@ class _LIBCPP_TYPE_VIS result_of<_Fn(_A0, _A1)> }; template <class _Fn, class _A0, class _A1, class _A2> -class _LIBCPP_TYPE_VIS result_of<_Fn(_A0, _A1, _A2)> +class _LIBCPP_TYPE_VIS_ONLY result_of<_Fn(_A0, _A1, _A2)> : public __result_of<_Fn(_A0, _A1, _A2), is_class<typename remove_reference<_Fn>::type>::value || is_function<typename remove_reference<_Fn>::type>::value, @@ -1964,8 +1979,6 @@ class _LIBCPP_TYPE_VIS result_of<_Fn(_A0, _A1, _A2)> // main is_constructible test -template<typename, typename T> struct __select_2nd { typedef T type; }; - template <class _Tp, class ..._Args> typename __select_2nd<decltype(_VSTD::move(_Tp(_VSTD::declval<_Args>()...))), true_type>::type __is_constructible_test(_Tp&&, _Args&& ...); @@ -2052,7 +2065,7 @@ struct __contains_void<_A0, _Args...> // is_constructible entry point template <class _Tp, class... _Args> -struct _LIBCPP_TYPE_VIS is_constructible +struct _LIBCPP_TYPE_VIS_ONLY is_constructible : public __is_constructible_void_check<__contains_void<_Tp, _Args...>::value || is_abstract<_Tp>::value, _Tp, _Args...> @@ -2200,7 +2213,7 @@ struct __nat {}; template <class _Tp, class _A0 = __is_construct::__nat, class _A1 = __is_construct::__nat> -struct _LIBCPP_TYPE_VIS is_constructible +struct _LIBCPP_TYPE_VIS_ONLY is_constructible : public __is_constructible2_void_check<is_void<_Tp>::value || is_abstract<_Tp>::value || is_function<_Tp>::value @@ -2210,7 +2223,7 @@ struct _LIBCPP_TYPE_VIS is_constructible {}; template <class _Tp> -struct _LIBCPP_TYPE_VIS is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat> +struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, __is_construct::__nat, __is_construct::__nat> : public __is_constructible0_void_check<is_void<_Tp>::value || is_abstract<_Tp>::value || is_function<_Tp>::value, @@ -2218,7 +2231,7 @@ struct _LIBCPP_TYPE_VIS is_constructible<_Tp, __is_construct::__nat, __is_constr {}; template <class _Tp, class _A0> -struct _LIBCPP_TYPE_VIS is_constructible<_Tp, _A0, __is_construct::__nat> +struct _LIBCPP_TYPE_VIS_ONLY is_constructible<_Tp, _A0, __is_construct::__nat> : public __is_constructible1_void_check<is_void<_Tp>::value || is_abstract<_Tp>::value || is_function<_Tp>::value @@ -2266,21 +2279,21 @@ struct __is_constructible2_imp<false, _Ap[], _A0, _A1> // is_default_constructible template <class _Tp> -struct _LIBCPP_TYPE_VIS is_default_constructible +struct _LIBCPP_TYPE_VIS_ONLY is_default_constructible : public is_constructible<_Tp> {}; // is_copy_constructible template <class _Tp> -struct _LIBCPP_TYPE_VIS is_copy_constructible +struct _LIBCPP_TYPE_VIS_ONLY is_copy_constructible : public is_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type> {}; // is_move_constructible template <class _Tp> -struct _LIBCPP_TYPE_VIS is_move_constructible +struct _LIBCPP_TYPE_VIS_ONLY is_move_constructible #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES : public is_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> #else @@ -2295,7 +2308,7 @@ struct _LIBCPP_TYPE_VIS is_move_constructible #if __has_feature(is_trivially_constructible) template <class _Tp, class... _Args> -struct _LIBCPP_TYPE_VIS is_trivially_constructible +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible : integral_constant<bool, __is_trivially_constructible(_Tp, _Args...)> { }; @@ -2303,13 +2316,13 @@ struct _LIBCPP_TYPE_VIS is_trivially_constructible #else // !__has_feature(is_trivially_constructible) template <class _Tp, class... _Args> -struct _LIBCPP_TYPE_VIS is_trivially_constructible +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible : false_type { }; template <class _Tp> -struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp> +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp> #if __has_feature(has_trivial_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant<bool, __has_trivial_constructor(_Tp)> #else @@ -2320,22 +2333,22 @@ struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp> template <class _Tp> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp&&> +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&&> #else -struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp> +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp> #endif : integral_constant<bool, is_scalar<_Tp>::value> { }; template <class _Tp> -struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, const _Tp&> +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&> : integral_constant<bool, is_scalar<_Tp>::value> { }; template <class _Tp> -struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp&> +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&> : integral_constant<bool, is_scalar<_Tp>::value> { }; @@ -2346,7 +2359,7 @@ struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp&> template <class _Tp, class _A0 = __is_construct::__nat, class _A1 = __is_construct::__nat> -struct _LIBCPP_TYPE_VIS is_trivially_constructible +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible : false_type { }; @@ -2354,28 +2367,28 @@ struct _LIBCPP_TYPE_VIS is_trivially_constructible #if __has_feature(is_trivially_constructible) template <class _Tp> -struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, __is_construct::__nat, +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat, __is_construct::__nat> : integral_constant<bool, __is_trivially_constructible(_Tp)> { }; template <class _Tp> -struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp, +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp, __is_construct::__nat> : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp)> { }; template <class _Tp> -struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, const _Tp&, +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&, __is_construct::__nat> : integral_constant<bool, __is_trivially_constructible(_Tp, const _Tp&)> { }; template <class _Tp> -struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp&, +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&, __is_construct::__nat> : integral_constant<bool, __is_trivially_constructible(_Tp, _Tp&)> { @@ -2384,28 +2397,28 @@ struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp&, #else // !__has_feature(is_trivially_constructible) template <class _Tp> -struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, __is_construct::__nat, +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, __is_construct::__nat, __is_construct::__nat> : integral_constant<bool, is_scalar<_Tp>::value> { }; template <class _Tp> -struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp, +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp, __is_construct::__nat> : integral_constant<bool, is_scalar<_Tp>::value> { }; template <class _Tp> -struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, const _Tp&, +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, const _Tp&, __is_construct::__nat> : integral_constant<bool, is_scalar<_Tp>::value> { }; template <class _Tp> -struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp&, +struct _LIBCPP_TYPE_VIS_ONLY is_trivially_constructible<_Tp, _Tp&, __is_construct::__nat> : integral_constant<bool, is_scalar<_Tp>::value> { @@ -2417,19 +2430,19 @@ struct _LIBCPP_TYPE_VIS is_trivially_constructible<_Tp, _Tp&, // is_trivially_default_constructible -template <class _Tp> struct _LIBCPP_TYPE_VIS is_trivially_default_constructible +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_default_constructible : public is_trivially_constructible<_Tp> {}; // is_trivially_copy_constructible -template <class _Tp> struct _LIBCPP_TYPE_VIS is_trivially_copy_constructible +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_constructible : public is_trivially_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type> {}; // is_trivially_move_constructible -template <class _Tp> struct _LIBCPP_TYPE_VIS is_trivially_move_constructible +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_constructible #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES : public is_trivially_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> #else @@ -2477,14 +2490,14 @@ struct is_trivially_assignable<_Tp&, _Tp&&> // is_trivially_copy_assignable -template <class _Tp> struct _LIBCPP_TYPE_VIS is_trivially_copy_assignable +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copy_assignable : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, const typename add_lvalue_reference<_Tp>::type> {}; // is_trivially_move_assignable -template <class _Tp> struct _LIBCPP_TYPE_VIS is_trivially_move_assignable +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_move_assignable : public is_trivially_assignable<typename add_lvalue_reference<_Tp>::type, #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES typename add_rvalue_reference<_Tp>::type> @@ -2497,7 +2510,7 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS is_trivially_move_assignable #if __has_feature(has_trivial_destructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) -template <class _Tp> struct _LIBCPP_TYPE_VIS is_trivially_destructible +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible : public integral_constant<bool, __has_trivial_destructor(_Tp)> {}; #else // _LIBCPP_HAS_TYPE_TRAITS @@ -2506,7 +2519,7 @@ template <class _Tp> struct __libcpp_trivial_destructor : public integral_constant<bool, is_scalar<_Tp>::value || is_reference<_Tp>::value> {}; -template <class _Tp> struct _LIBCPP_TYPE_VIS is_trivially_destructible +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_destructible : public __libcpp_trivial_destructor<typename remove_all_extents<_Tp>::type> {}; #endif // _LIBCPP_HAS_TYPE_TRAITS @@ -2532,13 +2545,13 @@ struct __is_nothrow_constructible<false, _Tp, _Args...> }; template <class _Tp, class... _Args> -struct _LIBCPP_TYPE_VIS is_nothrow_constructible +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible : __is_nothrow_constructible<is_constructible<_Tp, _Args...>::value, _Tp, _Args...> { }; template <class _Tp, size_t _Ns> -struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp[_Ns]> +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp[_Ns]> : __is_nothrow_constructible<is_constructible<_Tp>::value, _Tp> { }; @@ -2546,13 +2559,13 @@ struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp[_Ns]> #else // __has_feature(cxx_noexcept) template <class _Tp, class... _Args> -struct _LIBCPP_TYPE_VIS is_nothrow_constructible +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible : false_type { }; template <class _Tp> -struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp> +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp> #if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant<bool, __has_nothrow_constructor(_Tp)> #else @@ -2563,9 +2576,9 @@ struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp> template <class _Tp> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp&&> +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&&> #else -struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp> +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp> #endif #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant<bool, __has_nothrow_copy(_Tp)> @@ -2576,7 +2589,7 @@ struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp> }; template <class _Tp> -struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, const _Tp&> +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&> #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant<bool, __has_nothrow_copy(_Tp)> #else @@ -2586,7 +2599,7 @@ struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, const _Tp&> }; template <class _Tp> -struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp&> +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&> #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant<bool, __has_nothrow_copy(_Tp)> #else @@ -2601,13 +2614,13 @@ struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp&> template <class _Tp, class _A0 = __is_construct::__nat, class _A1 = __is_construct::__nat> -struct _LIBCPP_TYPE_VIS is_nothrow_constructible +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible : false_type { }; template <class _Tp> -struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, __is_construct::__nat, +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, __is_construct::__nat, __is_construct::__nat> #if __has_feature(has_nothrow_constructor) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant<bool, __has_nothrow_constructor(_Tp)> @@ -2618,7 +2631,7 @@ struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, __is_construct::__nat, }; template <class _Tp> -struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp, +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp, __is_construct::__nat> #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant<bool, __has_nothrow_copy(_Tp)> @@ -2629,7 +2642,7 @@ struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp, }; template <class _Tp> -struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, const _Tp&, +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, const _Tp&, __is_construct::__nat> #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant<bool, __has_nothrow_copy(_Tp)> @@ -2640,7 +2653,7 @@ struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, const _Tp&, }; template <class _Tp> -struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp&, +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_constructible<_Tp, _Tp&, __is_construct::__nat> #if __has_feature(has_nothrow_copy) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant<bool, __has_nothrow_copy(_Tp)> @@ -2654,19 +2667,19 @@ struct _LIBCPP_TYPE_VIS is_nothrow_constructible<_Tp, _Tp&, // is_nothrow_default_constructible -template <class _Tp> struct _LIBCPP_TYPE_VIS is_nothrow_default_constructible +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_default_constructible : public is_nothrow_constructible<_Tp> {}; // is_nothrow_copy_constructible -template <class _Tp> struct _LIBCPP_TYPE_VIS is_nothrow_copy_constructible +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_constructible : public is_nothrow_constructible<_Tp, const typename add_lvalue_reference<_Tp>::type> {}; // is_nothrow_move_constructible -template <class _Tp> struct _LIBCPP_TYPE_VIS is_nothrow_move_constructible +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_constructible #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES : public is_nothrow_constructible<_Tp, typename add_rvalue_reference<_Tp>::type> #else @@ -2693,7 +2706,7 @@ struct __is_nothrow_assignable<true, _Tp, _Arg> }; template <class _Tp, class _Arg> -struct _LIBCPP_TYPE_VIS is_nothrow_assignable +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable : public __is_nothrow_assignable<is_assignable<_Tp, _Arg>::value, _Tp, _Arg> { }; @@ -2701,11 +2714,11 @@ struct _LIBCPP_TYPE_VIS is_nothrow_assignable #else // __has_feature(cxx_noexcept) template <class _Tp, class _Arg> -struct _LIBCPP_TYPE_VIS is_nothrow_assignable +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable : public false_type {}; template <class _Tp> -struct _LIBCPP_TYPE_VIS is_nothrow_assignable<_Tp&, _Tp> +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp> #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; #else @@ -2713,7 +2726,7 @@ struct _LIBCPP_TYPE_VIS is_nothrow_assignable<_Tp&, _Tp> #endif template <class _Tp> -struct _LIBCPP_TYPE_VIS is_nothrow_assignable<_Tp&, _Tp&> +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, _Tp&> #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; #else @@ -2721,7 +2734,7 @@ struct _LIBCPP_TYPE_VIS is_nothrow_assignable<_Tp&, _Tp&> #endif template <class _Tp> -struct _LIBCPP_TYPE_VIS is_nothrow_assignable<_Tp&, const _Tp&> +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_assignable<_Tp&, const _Tp&> #if __has_feature(has_nothrow_assign) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) : integral_constant<bool, __has_nothrow_assign(_Tp)> {}; #else @@ -2744,14 +2757,14 @@ struct is_nothrow_assignable<_Tp&, _Tp&&> // is_nothrow_copy_assignable -template <class _Tp> struct _LIBCPP_TYPE_VIS is_nothrow_copy_assignable +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_copy_assignable : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, const typename add_lvalue_reference<_Tp>::type> {}; // is_nothrow_move_assignable -template <class _Tp> struct _LIBCPP_TYPE_VIS is_nothrow_move_assignable +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_move_assignable : public is_nothrow_assignable<typename add_lvalue_reference<_Tp>::type, #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES typename add_rvalue_reference<_Tp>::type> @@ -2779,19 +2792,19 @@ struct __is_nothrow_destructible<true, _Tp> }; template <class _Tp> -struct _LIBCPP_TYPE_VIS is_nothrow_destructible +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible : public __is_nothrow_destructible<is_destructible<_Tp>::value, _Tp> { }; template <class _Tp, size_t _Ns> -struct _LIBCPP_TYPE_VIS is_nothrow_destructible<_Tp[_Ns]> +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp[_Ns]> : public is_nothrow_destructible<_Tp> { }; template <class _Tp> -struct _LIBCPP_TYPE_VIS is_nothrow_destructible<_Tp&> +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&> : public true_type { }; @@ -2799,7 +2812,7 @@ struct _LIBCPP_TYPE_VIS is_nothrow_destructible<_Tp&> #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class _Tp> -struct _LIBCPP_TYPE_VIS is_nothrow_destructible<_Tp&&> +struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible<_Tp&&> : public true_type { }; @@ -2812,7 +2825,7 @@ template <class _Tp> struct __libcpp_nothrow_destructor : public integral_constant<bool, is_scalar<_Tp>::value || is_reference<_Tp>::value> {}; -template <class _Tp> struct _LIBCPP_TYPE_VIS is_nothrow_destructible +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_nothrow_destructible : public __libcpp_nothrow_destructor<typename remove_all_extents<_Tp>::type> {}; #endif @@ -2821,12 +2834,12 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS is_nothrow_destructible #if __has_feature(is_pod) || (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3) -template <class _Tp> struct _LIBCPP_TYPE_VIS is_pod +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod : public integral_constant<bool, __is_pod(_Tp)> {}; #else // _LIBCPP_HAS_TYPE_TRAITS -template <class _Tp> struct _LIBCPP_TYPE_VIS is_pod +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_pod : public integral_constant<bool, is_trivially_default_constructible<_Tp>::value && is_trivially_copy_constructible<_Tp>::value && is_trivially_copy_assignable<_Tp>::value && @@ -2836,7 +2849,7 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS is_pod // is_literal_type; -template <class _Tp> struct _LIBCPP_TYPE_VIS is_literal_type +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_literal_type #if __has_feature(is_literal) : public integral_constant<bool, __is_literal(_Tp)> #else @@ -2847,7 +2860,7 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS is_literal_type // is_standard_layout; -template <class _Tp> struct _LIBCPP_TYPE_VIS is_standard_layout +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_standard_layout #if __has_feature(is_standard_layout) : public integral_constant<bool, __is_standard_layout(_Tp)> #else @@ -2857,7 +2870,7 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS is_standard_layout // is_trivially_copyable; -template <class _Tp> struct _LIBCPP_TYPE_VIS is_trivially_copyable +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivially_copyable #if __has_feature(is_trivially_copyable) : public integral_constant<bool, __is_trivially_copyable(_Tp)> #else @@ -2867,7 +2880,7 @@ template <class _Tp> struct _LIBCPP_TYPE_VIS is_trivially_copyable // is_trivial; -template <class _Tp> struct _LIBCPP_TYPE_VIS is_trivial +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY is_trivial #if __has_feature(is_trivial) : public integral_constant<bool, __is_trivial(_Tp)> #else @@ -2924,12 +2937,22 @@ struct __check_complete<_Rp (*)(_Param...)> { }; +template <class ..._Param> +struct __check_complete<void (*)(_Param...)> +{ +}; + template <class _Rp, class ..._Param> struct __check_complete<_Rp (_Param...)> : private __check_complete<_Rp> { }; +template <class ..._Param> +struct __check_complete<void (_Param...)> +{ +}; + template <class _Rp, class _Class, class ..._Param> struct __check_complete<_Rp (_Class::*)(_Param...)> : private __check_complete<_Class> @@ -3124,7 +3147,7 @@ struct __invoke_of }; template <class _Fp, class ..._Args> -class _LIBCPP_TYPE_VIS result_of<_Fp(_Args...)> +class _LIBCPP_TYPE_VIS_ONLY result_of<_Fp(_Args...)> : public __invoke_of<_Fp, _Args...> { }; @@ -3243,6 +3266,27 @@ struct underlying_type #endif // _LIBCXX_UNDERLYING_TYPE +#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE + +template <class _Tp> +struct __has_operator_addressof_imp +{ + template <class> + static auto __test(__any) -> false_type; + template <class _Up> + static auto __test(_Up* __u) + -> typename __select_2nd<decltype(__u->operator&()), true_type>::type; + + static const bool value = decltype(__test<_Tp>(nullptr))::value; +}; + +template <class _Tp> +struct __has_operator_addressof + : public integral_constant<bool, __has_operator_addressof_imp<_Tp>::value> +{}; + +#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE + _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_TYPE_TRAITS diff --git a/system/include/libcxx/typeindex b/system/include/libcxx/typeindex index 67462b74..d4d6ca96 100644 --- a/system/include/libcxx/typeindex +++ b/system/include/libcxx/typeindex @@ -55,7 +55,7 @@ struct hash<type_index> _LIBCPP_BEGIN_NAMESPACE_STD -class _LIBCPP_TYPE_VIS type_index +class _LIBCPP_TYPE_VIS_ONLY type_index { const type_info* __t_; public: @@ -87,10 +87,10 @@ public: const char* name() const _NOEXCEPT {return __t_->name();} }; -template <class _Tp> struct _LIBCPP_TYPE_VIS hash; +template <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY hash; template <> -struct _LIBCPP_TYPE_VIS hash<type_index> +struct _LIBCPP_TYPE_VIS_ONLY hash<type_index> : public unary_function<type_index, size_t> { _LIBCPP_INLINE_VISIBILITY diff --git a/system/include/libcxx/unordered_map b/system/include/libcxx/unordered_map index eebf2f5e..78fee481 100644 --- a/system/include/libcxx/unordered_map +++ b/system/include/libcxx/unordered_map @@ -69,6 +69,22 @@ public: unordered_map(initializer_list<value_type>, size_type n = 0, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); + unordered_map(size_type n, const allocator_type& a) + : unordered_map(n, hasher(), key_equal(), a) {} // C++14 + unordered_map(size_type n, const hasher& hf, const allocator_type& a) + : unordered_map(n, hf, key_equal(), a) {} // C++14 + template <class InputIterator> + unordered_map(InputIterator f, InputIterator l, size_type n, const allocator_type& a) + : unordered_map(f, l, n, hasher(), key_equal(), a) {} // C++14 + template <class InputIterator> + unordered_map(InputIterator f, InputIterator l, size_type n, const hasher& hf, + const allocator_type& a) + : unordered_map(f, l, n, hf, key_equal(), a) {} // C++14 + unordered_map(initializer_list<value_type> il, size_type n, const allocator_type& a) + : unordered_map(il, n, hasher(), key_equal(), a) {} // C++14 + unordered_map(initializer_list<value_type> il, size_type n, const hasher& hf, + const allocator_type& a) + : unordered_map(il, n, hf, key_equal(), a) {} // C++14 ~unordered_map(); unordered_map& operator=(const unordered_map&); unordered_map& operator=(unordered_map&&) @@ -217,6 +233,22 @@ public: unordered_multimap(initializer_list<value_type>, size_type n = 0, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); + unordered_multimap(size_type n, const allocator_type& a) + : unordered_multimap(n, hasher(), key_equal(), a) {} // C++14 + unordered_multimap(size_type n, const hasher& hf, const allocator_type& a) + : unordered_multimap(n, hf, key_equal(), a) {} // C++14 + template <class InputIterator> + unordered_multimap(InputIterator f, InputIterator l, size_type n, const allocator_type& a) + : unordered_multimap(f, l, n, hasher(), key_equal(), a) {} // C++14 + template <class InputIterator> + unordered_multimap(InputIterator f, InputIterator l, size_type n, const hasher& hf, + const allocator_type& a) + : unordered_multimap(f, l, n, hf, key_equal(), a) {} // C++14 + unordered_multimap(initializer_list<value_type> il, size_type n, const allocator_type& a) + : unordered_multimap(il, n, hasher(), key_equal(), a) {} // C++14 + unordered_multimap(initializer_list<value_type> il, size_type n, const hasher& hf, + const allocator_type& a) + : unordered_multimap(il, n, hf, key_equal(), a) {} // C++14 ~unordered_multimap(); unordered_multimap& operator=(const unordered_multimap&); unordered_multimap& operator=(unordered_multimap&&) @@ -493,8 +525,73 @@ public: } }; +#if __cplusplus >= 201103L + +template <class _Key, class _Tp> +union __hash_value_type +{ + typedef _Key key_type; + typedef _Tp mapped_type; + typedef pair<const key_type, mapped_type> value_type; + typedef pair<key_type, mapped_type> __nc_value_type; + + value_type __cc; + __nc_value_type __nc; + + template <class ..._Args> + _LIBCPP_INLINE_VISIBILITY + __hash_value_type(_Args&& ...__args) + : __cc(std::forward<_Args>(__args)...) {} + + _LIBCPP_INLINE_VISIBILITY + __hash_value_type(const __hash_value_type& __v) + : __cc(__v.__cc) {} + + _LIBCPP_INLINE_VISIBILITY + __hash_value_type(__hash_value_type&& __v) + : __nc(std::move(__v.__nc)) {} + + _LIBCPP_INLINE_VISIBILITY + __hash_value_type& operator=(const __hash_value_type& __v) + {__nc = __v.__cc; return *this;} + + _LIBCPP_INLINE_VISIBILITY + __hash_value_type& operator=(__hash_value_type&& __v) + {__nc = std::move(__v.__nc); return *this;} + + _LIBCPP_INLINE_VISIBILITY + ~__hash_value_type() {__cc.~value_type();} +}; + +#else + +template <class _Key, class _Tp> +struct __hash_value_type +{ + typedef _Key key_type; + typedef _Tp mapped_type; + typedef pair<const key_type, mapped_type> value_type; + + value_type __cc; + + _LIBCPP_INLINE_VISIBILITY + __hash_value_type() {} + + template <class _A0> + _LIBCPP_INLINE_VISIBILITY + __hash_value_type(const _A0& __a0) + : __cc(__a0) {} + + template <class _A0, class _A1> + _LIBCPP_INLINE_VISIBILITY + __hash_value_type(const _A0& __a0, const _A1& __a1) + : __cc(__a0, __a1) {} +}; + +#endif + template <class _HashIterator> -class _LIBCPP_TYPE_VIS __hash_map_iterator +class _LIBCPP_TYPE_VIS_ONLY __hash_map_iterator { _HashIterator __i_; @@ -542,15 +639,15 @@ public: bool operator!=(const __hash_map_iterator& __x, const __hash_map_iterator& __y) {return __x.__i_ != __y.__i_;} - template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS unordered_map; - template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS unordered_multimap; - template <class> friend class _LIBCPP_TYPE_VIS __hash_const_iterator; - template <class> friend class _LIBCPP_TYPE_VIS __hash_const_local_iterator; - template <class> friend class _LIBCPP_TYPE_VIS __hash_map_const_iterator; + template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_map; + template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator; }; template <class _HashIterator> -class _LIBCPP_TYPE_VIS __hash_map_const_iterator +class _LIBCPP_TYPE_VIS_ONLY __hash_map_const_iterator { _HashIterator __i_; @@ -603,15 +700,15 @@ public: bool operator!=(const __hash_map_const_iterator& __x, const __hash_map_const_iterator& __y) {return __x.__i_ != __y.__i_;} - template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS unordered_map; - template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS unordered_multimap; - template <class> friend class _LIBCPP_TYPE_VIS __hash_const_iterator; - template <class> friend class _LIBCPP_TYPE_VIS __hash_const_local_iterator; + template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_map; + template <class, class, class, class, class> friend class _LIBCPP_TYPE_VIS_ONLY unordered_multimap; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_iterator; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY __hash_const_local_iterator; }; template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>, class _Alloc = allocator<pair<const _Key, _Tp> > > -class _LIBCPP_TYPE_VIS unordered_map +class _LIBCPP_TYPE_VIS_ONLY unordered_map { public: // types @@ -628,49 +725,7 @@ public: "Invalid allocator::value_type"); private: -#if __cplusplus >= 201103L - union __value_type - { - typedef typename unordered_map::value_type value_type; - typedef typename unordered_map::__nc_value_type __nc_value_type; - value_type __cc; - __nc_value_type __nc; - - template <class ..._Args> - __value_type(_Args&& ...__args) - : __cc(std::forward<_Args>(__args)...) {} - - __value_type(const __value_type& __v) - : __cc(std::move(__v.__cc)) {} - - __value_type(__value_type&& __v) - : __nc(std::move(__v.__nc)) {} - - __value_type& operator=(const __value_type& __v) - {__nc = __v.__cc; return *this;} - - __value_type& operator=(__value_type&& __v) - {__nc = std::move(__v.__nc); return *this;} - - ~__value_type() {__cc.~value_type();} - }; -#else - struct __value_type - { - typedef typename unordered_map::value_type value_type; - value_type __cc; - - __value_type() {} - - template <class _A0> - __value_type(const _A0& __a0) - : __cc(__a0) {} - - template <class _A0, class _A1> - __value_type(const _A0& __a0, const _A1& __a1) - : __cc(__a0, __a1) {} - }; -#endif + typedef __hash_value_type<key_type, mapped_type> __value_type; typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher; typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal; typedef typename allocator_traits<allocator_type>::template @@ -745,6 +800,30 @@ public: const hasher& __hf, const key_equal& __eql, const allocator_type& __a); #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#if _LIBCPP_STD_VER > 11 + _LIBCPP_INLINE_VISIBILITY + unordered_map(size_type __n, const allocator_type& __a) + : unordered_map(__n, hasher(), key_equal(), __a) {} + _LIBCPP_INLINE_VISIBILITY + unordered_map(size_type __n, const hasher& __hf, const allocator_type& __a) + : unordered_map(__n, __hf, key_equal(), __a) {} + template <class _InputIterator> + _LIBCPP_INLINE_VISIBILITY + unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a) + : unordered_map(__first, __last, __n, hasher(), key_equal(), __a) {} + template <class _InputIterator> + _LIBCPP_INLINE_VISIBILITY + unordered_map(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_map(__first, __last, __n, __hf, key_equal(), __a) {} + _LIBCPP_INLINE_VISIBILITY + unordered_map(initializer_list<value_type> __il, size_type __n, const allocator_type& __a) + : unordered_map(__il, __n, hasher(), key_equal(), __a) {} + _LIBCPP_INLINE_VISIBILITY + unordered_map(initializer_list<value_type> __il, size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_map(__il, __n, __hf, key_equal(), __a) {} +#endif // ~unordered_map() = default; _LIBCPP_INLINE_VISIBILITY unordered_map& operator=(const unordered_map& __u) @@ -1211,7 +1290,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(key_ty __h.get_deleter().__first_constructed = true; __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); __h.get_deleter().__second_constructed = true; - return _VSTD::move(__h); + return __h; } #ifndef _LIBCPP_HAS_NO_VARIADICS @@ -1258,7 +1337,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__construct_node_with_key(const __h.get_deleter().__first_constructed = true; __node_traits::construct(__na, _VSTD::addressof(__h->__value_.__cc.second)); __h.get_deleter().__second_constructed = true; - return _VSTD::move(__h); + return _VSTD::move(__h); // explicitly moved for C++03 } template <class _Key, class _Tp, class _Hash, class _Pred, class _Alloc> @@ -1366,7 +1445,7 @@ operator!=(const unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>& __x, template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = equal_to<_Key>, class _Alloc = allocator<pair<const _Key, _Tp> > > -class _LIBCPP_TYPE_VIS unordered_multimap +class _LIBCPP_TYPE_VIS_ONLY unordered_multimap { public: // types @@ -1383,49 +1462,7 @@ public: "Invalid allocator::value_type"); private: -#if __cplusplus >= 201103L - union __value_type - { - typedef typename unordered_multimap::value_type value_type; - typedef typename unordered_multimap::__nc_value_type __nc_value_type; - value_type __cc; - __nc_value_type __nc; - - template <class ..._Args> - __value_type(_Args&& ...__args) - : __cc(std::forward<_Args>(__args)...) {} - - __value_type(const __value_type& __v) - : __cc(std::move(__v.__cc)) {} - - __value_type(__value_type&& __v) - : __nc(std::move(__v.__nc)) {} - - __value_type& operator=(const __value_type& __v) - {__nc = __v.__cc; return *this;} - - __value_type& operator=(__value_type&& __v) - {__nc = std::move(__v.__nc); return *this;} - - ~__value_type() {__cc.~value_type();} - }; -#else - struct __value_type - { - typedef typename unordered_multimap::value_type value_type; - value_type __cc; - - __value_type() {} - - template <class _A0> - __value_type(const _A0& __a0) - : __cc(__a0) {} - - template <class _A0, class _A1> - __value_type(const _A0& __a0, const _A1& __a1) - : __cc(__a0, __a1) {} - }; -#endif + typedef __hash_value_type<key_type, mapped_type> __value_type; typedef __unordered_map_hasher<key_type, __value_type, hasher> __hasher; typedef __unordered_map_equal<key_type, __value_type, key_equal> __key_equal; typedef typename allocator_traits<allocator_type>::template @@ -1499,6 +1536,30 @@ public: const hasher& __hf, const key_equal& __eql, const allocator_type& __a); #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#if _LIBCPP_STD_VER > 11 + _LIBCPP_INLINE_VISIBILITY + unordered_multimap(size_type __n, const allocator_type& __a) + : unordered_multimap(__n, hasher(), key_equal(), __a) {} + _LIBCPP_INLINE_VISIBILITY + unordered_multimap(size_type __n, const hasher& __hf, const allocator_type& __a) + : unordered_multimap(__n, __hf, key_equal(), __a) {} + template <class _InputIterator> + _LIBCPP_INLINE_VISIBILITY + unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const allocator_type& __a) + : unordered_multimap(__first, __last, __n, hasher(), key_equal(), __a) {} + template <class _InputIterator> + _LIBCPP_INLINE_VISIBILITY + unordered_multimap(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_multimap(__first, __last, __n, __hf, key_equal(), __a) {} + _LIBCPP_INLINE_VISIBILITY + unordered_multimap(initializer_list<value_type> __il, size_type __n, const allocator_type& __a) + : unordered_multimap(__il, __n, hasher(), key_equal(), __a) {} + _LIBCPP_INLINE_VISIBILITY + unordered_multimap(initializer_list<value_type> __il, size_type __n, const hasher& __hf, + const allocator_type& __a) + : unordered_multimap(__il, __n, __hf, key_equal(), __a) {} +#endif // ~unordered_multimap() = default; _LIBCPP_INLINE_VISIBILITY unordered_multimap& operator=(const unordered_multimap& __u) diff --git a/system/include/libcxx/unordered_set b/system/include/libcxx/unordered_set index 8be36df6..fd378fa0 100644 --- a/system/include/libcxx/unordered_set +++ b/system/include/libcxx/unordered_set @@ -68,6 +68,16 @@ public: unordered_set(initializer_list<value_type>, size_type n = 0, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); + unordered_set(size_type n, const allocator_type& a); // C++14 + unordered_set(size_type n, const hasher& hf, const allocator_type& a); // C++14 + template <class InputIterator> + unordered_set(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14 + template <class InputIterator> + unordered_set(InputIterator f, InputIterator l, size_type n, + const hasher& hf, const allocator_type& a); // C++14 + unordered_set(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14 + unordered_set(initializer_list<value_type> il, size_type n, + const hasher& hf, const allocator_type& a); // C++14 ~unordered_set(); unordered_set& operator=(const unordered_set&); unordered_set& operator=(unordered_set&&) @@ -207,6 +217,16 @@ public: unordered_multiset(initializer_list<value_type>, size_type n = /see below/, const hasher& hf = hasher(), const key_equal& eql = key_equal(), const allocator_type& a = allocator_type()); + unordered_multiset(size_type n, const allocator_type& a); // C++14 + unordered_multiset(size_type n, const hasher& hf, const allocator_type& a); // C++14 + template <class InputIterator> + unordered_multiset(InputIterator f, InputIterator l, size_type n, const allocator_type& a); // C++14 + template <class InputIterator> + unordered_multiset(InputIterator f, InputIterator l, size_type n, + const hasher& hf, const allocator_type& a); // C++14 + unordered_multiset(initializer_list<value_type> il, size_type n, const allocator_type& a); // C++14 + unordered_multiset(initializer_list<value_type> il, size_type n, + const hasher& hf, const allocator_type& a); // C++14 ~unordered_multiset(); unordered_multiset& operator=(const unordered_multiset&); unordered_multiset& operator=(unordered_multiset&&) @@ -313,7 +333,7 @@ _LIBCPP_BEGIN_NAMESPACE_STD template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, class _Alloc = allocator<_Value> > -class _LIBCPP_TYPE_VIS unordered_set +class _LIBCPP_TYPE_VIS_ONLY unordered_set { public: // types @@ -353,6 +373,14 @@ public: } explicit unordered_set(size_type __n, const hasher& __hf = hasher(), const key_equal& __eql = key_equal()); +#if _LIBCPP_STD_VER > 11 + inline _LIBCPP_INLINE_VISIBILITY + unordered_set(size_type __n, const allocator_type& __a) + : unordered_set(__n, hasher(), key_equal(), __a) {} + inline _LIBCPP_INLINE_VISIBILITY + unordered_set(size_type __n, const hasher& __hf, const allocator_type& __a) + : unordered_set(__n, __hf, key_equal(), __a) {} +#endif unordered_set(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a); template <class _InputIterator> @@ -365,6 +393,17 @@ public: unordered_set(_InputIterator __first, _InputIterator __last, size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a); +#if _LIBCPP_STD_VER > 11 + template <class _InputIterator> + inline _LIBCPP_INLINE_VISIBILITY + unordered_set(_InputIterator __first, _InputIterator __last, + size_type __n, const allocator_type& __a) + : unordered_set(__first, __last, __n, hasher(), key_equal(), __a) {} + template <class _InputIterator> + unordered_set(_InputIterator __first, _InputIterator __last, + size_type __n, const hasher& __hf, const allocator_type& __a) + : unordered_set(__first, __last, __n, __hf, key_equal(), __a) {} +#endif explicit unordered_set(const allocator_type& __a); unordered_set(const unordered_set& __u); unordered_set(const unordered_set& __u, const allocator_type& __a); @@ -381,6 +420,16 @@ public: unordered_set(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a); +#if _LIBCPP_STD_VER > 11 + inline _LIBCPP_INLINE_VISIBILITY + unordered_set(initializer_list<value_type> __il, size_type __n, + const allocator_type& __a) + : unordered_set(__il, __n, hasher(), key_equal(), __a) {} + inline _LIBCPP_INLINE_VISIBILITY + unordered_set(initializer_list<value_type> __il, size_type __n, + const hasher& __hf, const allocator_type& __a) + : unordered_set(__il, __n, __hf, key_equal(), __a) {} +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS // ~unordered_set() = default; _LIBCPP_INLINE_VISIBILITY @@ -819,7 +868,7 @@ operator!=(const unordered_set<_Value, _Hash, _Pred, _Alloc>& __x, template <class _Value, class _Hash = hash<_Value>, class _Pred = equal_to<_Value>, class _Alloc = allocator<_Value> > -class _LIBCPP_TYPE_VIS unordered_multiset +class _LIBCPP_TYPE_VIS_ONLY unordered_multiset { public: // types @@ -861,6 +910,14 @@ public: const key_equal& __eql = key_equal()); unordered_multiset(size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a); +#if _LIBCPP_STD_VER > 11 + inline _LIBCPP_INLINE_VISIBILITY + unordered_multiset(size_type __n, const allocator_type& __a) + : unordered_multiset(__n, hasher(), key_equal(), __a) {} + inline _LIBCPP_INLINE_VISIBILITY + unordered_multiset(size_type __n, const hasher& __hf, const allocator_type& __a) + : unordered_multiset(__n, __hf, key_equal(), __a) {} +#endif template <class _InputIterator> unordered_multiset(_InputIterator __first, _InputIterator __last); template <class _InputIterator> @@ -871,6 +928,18 @@ public: unordered_multiset(_InputIterator __first, _InputIterator __last, size_type __n , const hasher& __hf, const key_equal& __eql, const allocator_type& __a); +#if _LIBCPP_STD_VER > 11 + template <class _InputIterator> + inline _LIBCPP_INLINE_VISIBILITY + unordered_multiset(_InputIterator __first, _InputIterator __last, + size_type __n, const allocator_type& __a) + : unordered_multiset(__first, __last, __n, hasher(), key_equal(), __a) {} + template <class _InputIterator> + inline _LIBCPP_INLINE_VISIBILITY + unordered_multiset(_InputIterator __first, _InputIterator __last, + size_type __n, const hasher& __hf, const allocator_type& __a) + : unordered_multiset(__first, __last, __n, __hf, key_equal(), __a) {} +#endif explicit unordered_multiset(const allocator_type& __a); unordered_multiset(const unordered_multiset& __u); unordered_multiset(const unordered_multiset& __u, const allocator_type& __a); @@ -887,6 +956,14 @@ public: unordered_multiset(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const key_equal& __eql, const allocator_type& __a); +#if _LIBCPP_STD_VER > 11 + inline _LIBCPP_INLINE_VISIBILITY + unordered_multiset(initializer_list<value_type> __il, size_type __n, const allocator_type& __a) + : unordered_multiset(__il, __n, hasher(), key_equal(), __a) {} + inline _LIBCPP_INLINE_VISIBILITY + unordered_multiset(initializer_list<value_type> __il, size_type __n, const hasher& __hf, const allocator_type& __a) + : unordered_multiset(__il, __n, __hf, key_equal(), __a) {} +#endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS // ~unordered_multiset() = default; _LIBCPP_INLINE_VISIBILITY diff --git a/system/include/libcxx/utility b/system/include/libcxx/utility index d36cf9dd..5fc2cf20 100644 --- a/system/include/libcxx/utility +++ b/system/include/libcxx/utility @@ -237,7 +237,7 @@ move_if_noexcept(_Tp& __x) _NOEXCEPT return _VSTD::move(__x); } -struct _LIBCPP_TYPE_VIS piecewise_construct_t { }; +struct _LIBCPP_TYPE_VIS_ONLY piecewise_construct_t { }; #if defined(_LIBCPP_HAS_NO_CONSTEXPR) || defined(_LIBCPP_BUILDING_UTILITY) extern const piecewise_construct_t piecewise_construct;// = piecewise_construct_t(); #else @@ -245,7 +245,7 @@ constexpr piecewise_construct_t piecewise_construct = piecewise_construct_t(); #endif template <class _T1, class _T2> -struct _LIBCPP_TYPE_VIS pair +struct _LIBCPP_TYPE_VIS_ONLY pair { typedef _T1 first_type; typedef _T2 second_type; @@ -462,7 +462,7 @@ swap(pair<_T1, _T2>& __x, pair<_T1, _T2>& __y) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -template <class _Tp> class _LIBCPP_TYPE_VIS reference_wrapper; +template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY reference_wrapper; template <class _Tp> struct ___make_pair_return @@ -504,36 +504,36 @@ make_pair(_T1 __x, _T2 __y) #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class _T1, class _T2> - class _LIBCPP_TYPE_VIS tuple_size<pair<_T1, _T2> > + class _LIBCPP_TYPE_VIS_ONLY tuple_size<pair<_T1, _T2> > : public integral_constant<size_t, 2> {}; template <class _T1, class _T2> - class _LIBCPP_TYPE_VIS tuple_size<const pair<_T1, _T2> > + class _LIBCPP_TYPE_VIS_ONLY tuple_size<const pair<_T1, _T2> > : public integral_constant<size_t, 2> {}; template <class _T1, class _T2> -class _LIBCPP_TYPE_VIS tuple_element<0, pair<_T1, _T2> > +class _LIBCPP_TYPE_VIS_ONLY tuple_element<0, pair<_T1, _T2> > { public: typedef _T1 type; }; template <class _T1, class _T2> -class _LIBCPP_TYPE_VIS tuple_element<1, pair<_T1, _T2> > +class _LIBCPP_TYPE_VIS_ONLY tuple_element<1, pair<_T1, _T2> > { public: typedef _T2 type; }; template <class _T1, class _T2> -class _LIBCPP_TYPE_VIS tuple_element<0, const pair<_T1, _T2> > +class _LIBCPP_TYPE_VIS_ONLY tuple_element<0, const pair<_T1, _T2> > { public: typedef const _T1 type; }; template <class _T1, class _T2> -class _LIBCPP_TYPE_VIS tuple_element<1, const pair<_T1, _T2> > +class _LIBCPP_TYPE_VIS_ONLY tuple_element<1, const pair<_T1, _T2> > { public: typedef const _T2 type; @@ -594,7 +594,7 @@ struct __get_pair<1> }; template <size_t _Ip, class _T1, class _T2> -_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_CONSTEXPR_AFTER_CXX11 +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Ip, pair<_T1, _T2> >::type& get(pair<_T1, _T2>& __p) _NOEXCEPT { @@ -602,7 +602,7 @@ get(pair<_T1, _T2>& __p) _NOEXCEPT } template <size_t _Ip, class _T1, class _T2> -_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_CONSTEXPR_AFTER_CXX11 +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const typename tuple_element<_Ip, pair<_T1, _T2> >::type& get(const pair<_T1, _T2>& __p) _NOEXCEPT { @@ -612,7 +612,7 @@ get(const pair<_T1, _T2>& __p) _NOEXCEPT #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template <size_t _Ip, class _T1, class _T2> -_LIBCPP_INLINE_VISIBILITY inline _LIBCPP_CONSTEXPR_AFTER_CXX11 +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 typename tuple_element<_Ip, pair<_T1, _T2> >::type&& get(pair<_T1, _T2>&& __p) _NOEXCEPT { @@ -623,42 +623,42 @@ get(pair<_T1, _T2>&& __p) _NOEXCEPT #if _LIBCPP_STD_VER > 11 template <class _T1, class _T2> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY constexpr _T1 & get(pair<_T1, _T2>& __p) _NOEXCEPT { return __get_pair<0>::get(__p); } template <class _T1, class _T2> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY constexpr _T1 const & get(pair<_T1, _T2> const& __p) _NOEXCEPT { return __get_pair<0>::get(__p); } template <class _T1, class _T2> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY constexpr _T1 && get(pair<_T1, _T2>&& __p) _NOEXCEPT { return __get_pair<0>::get(_VSTD::move(__p)); } template <class _T1, class _T2> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY constexpr _T1 & get(pair<_T2, _T1>& __p) _NOEXCEPT { return __get_pair<1>::get(__p); } template <class _T1, class _T2> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY constexpr _T1 const & get(pair<_T2, _T1> const& __p) _NOEXCEPT { return __get_pair<1>::get(__p); } template <class _T1, class _T2> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY constexpr _T1 && get(pair<_T2, _T1>&& __p) _NOEXCEPT { return __get_pair<1>::get(_VSTD::move(__p)); @@ -669,7 +669,7 @@ constexpr _T1 && get(pair<_T2, _T1>&& __p) _NOEXCEPT #if _LIBCPP_STD_VER > 11 template<class _Tp, _Tp... _Ip> -struct _LIBCPP_TYPE_VIS integer_sequence +struct _LIBCPP_TYPE_VIS_ONLY integer_sequence { typedef _Tp value_type; static_assert( is_integral<_Tp>::value, @@ -754,7 +754,7 @@ template<class... _Tp> #if _LIBCPP_STD_VER > 11 template<class _T1, class _T2 = _T1> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY _T1 exchange(_T1& __obj, _T2 && __new_value) { _T1 __old_value = _VSTD::move(__obj); diff --git a/system/include/libcxx/valarray b/system/include/libcxx/valarray index 71c8a74e..5113516e 100644 --- a/system/include/libcxx/valarray +++ b/system/include/libcxx/valarray @@ -354,9 +354,9 @@ template <class T> unspecified2 end(const valarray<T>& v); _LIBCPP_BEGIN_NAMESPACE_STD -template<class _Tp> class _LIBCPP_TYPE_VIS valarray; +template<class _Tp> class _LIBCPP_TYPE_VIS_ONLY valarray; -class _LIBCPP_TYPE_VIS slice +class _LIBCPP_TYPE_VIS_ONLY slice { size_t __start_; size_t __size_; @@ -381,11 +381,11 @@ public: _LIBCPP_INLINE_VISIBILITY size_t stride() const {return __stride_;} }; -template <class _Tp> class _LIBCPP_TYPE_VIS slice_array; +template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY slice_array; class _LIBCPP_TYPE_VIS gslice; -template <class _Tp> class _LIBCPP_TYPE_VIS gslice_array; -template <class _Tp> class _LIBCPP_TYPE_VIS mask_array; -template <class _Tp> class _LIBCPP_TYPE_VIS indirect_array; +template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY gslice_array; +template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY mask_array; +template <class _Tp> class _LIBCPP_TYPE_VIS_ONLY indirect_array; template <class _Tp> _LIBCPP_INLINE_VISIBILITY @@ -671,7 +671,7 @@ public: _LIBCPP_INLINE_VISIBILITY size_t size() const {return __size_;} - template <class> friend class _LIBCPP_TYPE_VIS valarray; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY valarray; }; template <class _ValExpr> @@ -786,7 +786,7 @@ template<class _Tp> struct __is_val_expr<valarray<_Tp> > : true_type {}; template<class _Tp> -class _LIBCPP_TYPE_VIS valarray +class _LIBCPP_TYPE_VIS_ONLY valarray { public: typedef _Tp value_type; @@ -976,12 +976,12 @@ public: void resize(size_t __n, value_type __x = value_type()); private: - template <class> friend class _LIBCPP_TYPE_VIS valarray; - template <class> friend class _LIBCPP_TYPE_VIS slice_array; - template <class> friend class _LIBCPP_TYPE_VIS gslice_array; - template <class> friend class _LIBCPP_TYPE_VIS mask_array; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY valarray; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY slice_array; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY gslice_array; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY mask_array; template <class> friend class __mask_expr; - template <class> friend class _LIBCPP_TYPE_VIS indirect_array; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY indirect_array; template <class> friend class __indirect_expr; template <class> friend class __val_expr; @@ -1006,6 +1006,10 @@ private: end(const valarray<_Up>& __v); }; +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::valarray(size_t)) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS valarray<size_t>::~valarray()) +_LIBCPP_EXTERN_TEMPLATE(_LIBCPP_FUNC_VIS void valarray<size_t>::resize(size_t, size_t)) + template <class _Op, class _Tp> struct _UnaryOp<_Op, valarray<_Tp> > { @@ -1091,7 +1095,7 @@ struct _BinaryOp<_Op, valarray<_Tp>, valarray<_Tp> > // slice_array template <class _Tp> -class _LIBCPP_TYPE_VIS slice_array +class _LIBCPP_TYPE_VIS_ONLY slice_array { public: typedef _Tp value_type; @@ -1461,7 +1465,7 @@ private: // gslice_array template <class _Tp> -class _LIBCPP_TYPE_VIS gslice_array +class _LIBCPP_TYPE_VIS_ONLY gslice_array { public: typedef _Tp value_type; @@ -1790,7 +1794,7 @@ gslice_array<_Tp>::operator=(const value_type& __x) const // mask_array template <class _Tp> -class _LIBCPP_TYPE_VIS mask_array +class _LIBCPP_TYPE_VIS_ONLY mask_array { public: typedef _Tp value_type; @@ -2134,7 +2138,7 @@ public: // indirect_array template <class _Tp> -class _LIBCPP_TYPE_VIS indirect_array +class _LIBCPP_TYPE_VIS_ONLY indirect_array { public: typedef _Tp value_type; @@ -2485,7 +2489,7 @@ public: _LIBCPP_INLINE_VISIBILITY size_t size() const {return __1d_.size();} - template <class> friend class _LIBCPP_TYPE_VIS valarray; + template <class> friend class _LIBCPP_TYPE_VIS_ONLY valarray; }; template<class _ValExpr> @@ -2624,7 +2628,7 @@ public: }; template<class _ValExpr> -__val_expr<_ValExpr>::operator valarray<result_type>() const +__val_expr<_ValExpr>::operator valarray<__val_expr::result_type>() const { valarray<result_type> __r; size_t __n = __expr_.size(); @@ -4770,10 +4774,6 @@ end(const valarray<_Tp>& __v) return __v.__end_; } -_LIBCPP_EXTERN_TEMPLATE(valarray<size_t>::valarray(size_t)) -_LIBCPP_EXTERN_TEMPLATE(valarray<size_t>::~valarray()) -_LIBCPP_EXTERN_TEMPLATE(void valarray<size_t>::resize(size_t, size_t)) - _LIBCPP_END_NAMESPACE_STD #endif // _LIBCPP_VALARRAY diff --git a/system/include/libcxx/vector b/system/include/libcxx/vector index 0758f75b..6ac78d5d 100644 --- a/system/include/libcxx/vector +++ b/system/include/libcxx/vector @@ -38,6 +38,7 @@ public: noexcept(is_nothrow_default_constructible<allocator_type>::value); explicit vector(const allocator_type&); explicit vector(size_type n); + explicit vector(size_type n, const allocator_type&); // C++14 vector(size_type n, const value_type& value, const allocator_type& = allocator_type()); template <class InputIterator> vector(InputIterator first, InputIterator last, const allocator_type& = allocator_type()); @@ -161,7 +162,8 @@ public: vector() noexcept(is_nothrow_default_constructible<allocator_type>::value); explicit vector(const allocator_type&); - explicit vector(size_type n, const value_type& value = value_type(), const allocator_type& = allocator_type()); + explicit vector(size_type n, const allocator_type& a = allocator_type()); // C++14 + vector(size_type n, const value_type& value, const allocator_type& = allocator_type()); template <class InputIterator> vector(InputIterator first, InputIterator last, const allocator_type& = allocator_type()); vector(const vector& x); @@ -216,8 +218,10 @@ public: const_reference back() const; void push_back(const value_type& x); + template <class... Args> void emplace_back(Args&&... args); // C++14 void pop_back(); + template <class... Args> iterator emplace(const_iterator position, Args&&... args); // C++14 iterator insert(const_iterator position, const value_type& x); iterator insert(const_iterator position, size_type n, const value_type& x); template <class InputIterator> @@ -272,7 +276,7 @@ void swap(vector<T,Allocator>& x, vector<T,Allocator>& y) #include <__undef_min_max> -#ifdef _LIBCPP_DEBUG2 +#ifdef _LIBCPP_DEBUG # include <__debug> #else # define _LIBCPP_ASSERT(x, m) ((void)0) @@ -319,7 +323,7 @@ __vector_base_common<__b>::__throw_out_of_range() const #pragma warning( push ) #pragma warning( disable: 4231 ) #endif // _LIBCPP_MSVC -_LIBCPP_EXTERN_TEMPLATE(class __vector_base_common<true>) +_LIBCPP_EXTERN_TEMPLATE(class _LIBCPP_TYPE_VIS __vector_base_common<true>) #ifdef _LIBCPP_MSVC #pragma warning( pop ) #endif // _LIBCPP_MSVC @@ -436,7 +440,7 @@ private: }; template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void __vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT { @@ -445,7 +449,7 @@ __vector_base<_Tp, _Allocator>::__destruct_at_end(pointer __new_last) _NOEXCEPT } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY __vector_base<_Tp, _Allocator>::__vector_base() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) : __begin_(nullptr), @@ -455,7 +459,7 @@ __vector_base<_Tp, _Allocator>::__vector_base() } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY __vector_base<_Tp, _Allocator>::__vector_base(const allocator_type& __a) : __begin_(nullptr), __end_(nullptr), @@ -474,7 +478,7 @@ __vector_base<_Tp, _Allocator>::~__vector_base() } template <class _Tp, class _Allocator = allocator<_Tp> > -class _LIBCPP_TYPE_VIS vector +class _LIBCPP_TYPE_VIS_ONLY vector : private __vector_base<_Tp, _Allocator> { private: @@ -514,15 +518,19 @@ public: #endif } explicit vector(size_type __n); +#if _LIBCPP_STD_VER > 11 + explicit vector(size_type __n, const allocator_type& __a); +#endif vector(size_type __n, const_reference __x); vector(size_type __n, const_reference __x, const allocator_type& __a); template <class _InputIterator> - vector(_InputIterator __first, _InputIterator __last, + vector(_InputIterator __first, typename enable_if<__is_input_iterator <_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value && is_constructible< value_type, - typename iterator_traits<_InputIterator>::reference>::value>::type* = 0); + typename iterator_traits<_InputIterator>::reference>::value, + _InputIterator>::type __last); template <class _InputIterator> vector(_InputIterator __first, _InputIterator __last, const allocator_type& __a, typename enable_if<__is_input_iterator <_InputIterator>::value && @@ -531,11 +539,12 @@ public: value_type, typename iterator_traits<_InputIterator>::reference>::value>::type* = 0); template <class _ForwardIterator> - vector(_ForwardIterator __first, _ForwardIterator __last, + vector(_ForwardIterator __first, typename enable_if<__is_forward_iterator<_ForwardIterator>::value && is_constructible< value_type, - typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0); + typename iterator_traits<_ForwardIterator>::reference>::value, + _ForwardIterator>::type __last); template <class _ForwardIterator> vector(_ForwardIterator __first, _ForwardIterator __last, const allocator_type& __a, typename enable_if<__is_forward_iterator<_ForwardIterator>::value && @@ -888,7 +897,7 @@ vector<_Tp, _Allocator>::max_size() const _NOEXCEPT // Precondition: __new_size > capacity() template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::size_type vector<_Tp, _Allocator>::__recommend(size_type __new_size) const { @@ -926,7 +935,7 @@ vector<_Tp, _Allocator>::__construct_at_end(size_type __n) // Postcondition: size() == old size() + __n // Postcondition: [i] == __x for all i in [size() - __n, __n) template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::__construct_at_end(size_type __n, const_reference __x) { @@ -1020,6 +1029,22 @@ vector<_Tp, _Allocator>::vector(size_type __n) } } +#if _LIBCPP_STD_VER > 11 +template <class _Tp, class _Allocator> +vector<_Tp, _Allocator>::vector(size_type __n, const allocator_type& __a) + : __base(__a) +{ +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif + if (__n > 0) + { + allocate(__n); + __construct_at_end(__n); + } +} +#endif + template <class _Tp, class _Allocator> vector<_Tp, _Allocator>::vector(size_type __n, const_reference __x) { @@ -1049,12 +1074,13 @@ vector<_Tp, _Allocator>::vector(size_type __n, const_reference __x, const alloca template <class _Tp, class _Allocator> template <class _InputIterator> -vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, +vector<_Tp, _Allocator>::vector(_InputIterator __first, typename enable_if<__is_input_iterator <_InputIterator>::value && !__is_forward_iterator<_InputIterator>::value && is_constructible< value_type, - typename iterator_traits<_InputIterator>::reference>::value>::type*) + typename iterator_traits<_InputIterator>::reference>::value, + _InputIterator>::type __last) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); @@ -1082,11 +1108,12 @@ vector<_Tp, _Allocator>::vector(_InputIterator __first, _InputIterator __last, c template <class _Tp, class _Allocator> template <class _ForwardIterator> -vector<_Tp, _Allocator>::vector(_ForwardIterator __first, _ForwardIterator __last, +vector<_Tp, _Allocator>::vector(_ForwardIterator __first, typename enable_if<__is_forward_iterator<_ForwardIterator>::value && is_constructible< value_type, - typename iterator_traits<_ForwardIterator>::reference>::value>::type*) + typename iterator_traits<_ForwardIterator>::reference>::value, + _ForwardIterator>::type __last) { #if _LIBCPP_DEBUG_LEVEL >= 2 __get_db()->__insert_c(this); @@ -1152,7 +1179,7 @@ vector<_Tp, _Allocator>::vector(const vector& __x, const allocator_type& __a) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(vector&& __x) _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) : __base(_VSTD::move(__x.__alloc())) @@ -1168,7 +1195,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x) } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(vector&& __x, const allocator_type& __a) : __base(__a) { @@ -1195,7 +1222,7 @@ vector<_Tp, _Allocator>::vector(vector&& __x, const allocator_type& __a) #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il) { #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -1209,7 +1236,7 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il) } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocator_type& __a) : __base(__a) { @@ -1226,7 +1253,7 @@ vector<_Tp, _Allocator>::vector(initializer_list<value_type> __il, const allocat #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>& vector<_Tp, _Allocator>::operator=(vector&& __x) _NOEXCEPT_( @@ -1270,7 +1297,7 @@ vector<_Tp, _Allocator>::__move_assign(vector& __c, true_type) #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector<_Tp, _Allocator>& vector<_Tp, _Allocator>::operator=(const vector& __x) { @@ -1359,7 +1386,7 @@ vector<_Tp, _Allocator>::assign(size_type __n, const_reference __u) } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::__make_iter(pointer __p) _NOEXCEPT { @@ -1371,7 +1398,7 @@ vector<_Tp, _Allocator>::__make_iter(pointer __p) _NOEXCEPT } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::const_iterator vector<_Tp, _Allocator>::__make_iter(const_pointer __p) const _NOEXCEPT { @@ -1383,7 +1410,7 @@ vector<_Tp, _Allocator>::__make_iter(const_pointer __p) const _NOEXCEPT } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::begin() _NOEXCEPT { @@ -1391,7 +1418,7 @@ vector<_Tp, _Allocator>::begin() _NOEXCEPT } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::const_iterator vector<_Tp, _Allocator>::begin() const _NOEXCEPT { @@ -1399,7 +1426,7 @@ vector<_Tp, _Allocator>::begin() const _NOEXCEPT } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::end() _NOEXCEPT { @@ -1407,7 +1434,7 @@ vector<_Tp, _Allocator>::end() _NOEXCEPT } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::const_iterator vector<_Tp, _Allocator>::end() const _NOEXCEPT { @@ -1415,7 +1442,7 @@ vector<_Tp, _Allocator>::end() const _NOEXCEPT } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::reference vector<_Tp, _Allocator>::operator[](size_type __n) { @@ -1424,7 +1451,7 @@ vector<_Tp, _Allocator>::operator[](size_type __n) } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::const_reference vector<_Tp, _Allocator>::operator[](size_type __n) const { @@ -1502,7 +1529,7 @@ vector<_Tp, _Allocator>::__push_back_slow_path(_Up& __x) } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::push_back(const_reference __x) { @@ -1519,7 +1546,7 @@ vector<_Tp, _Allocator>::push_back(const_reference __x) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::push_back(value_type&& __x) { @@ -1551,7 +1578,7 @@ vector<_Tp, _Allocator>::__emplace_back_slow_path(_Args&&... __args) template <class _Tp, class _Allocator> template <class... _Args> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) { @@ -1570,7 +1597,7 @@ vector<_Tp, _Allocator>::emplace_back(_Args&&... __args) #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::pop_back() { @@ -1579,7 +1606,7 @@ vector<_Tp, _Allocator>::pop_back() } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<_Tp, _Allocator>::iterator vector<_Tp, _Allocator>::erase(const_iterator __position) { @@ -1989,7 +2016,7 @@ vector<_Tp, _Allocator>::__subscriptable(const const_iterator* __i, ptrdiff_t __ #endif // _LIBCPP_DEBUG_LEVEL >= 2 template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void vector<_Tp, _Allocator>::__invalidate_all_iterators() { @@ -2011,7 +2038,7 @@ struct __has_storage_type<vector<bool, _Allocator> > }; template <class _Allocator> -class _LIBCPP_TYPE_VIS vector<bool, _Allocator> +class _LIBCPP_TYPE_VIS_ONLY vector<bool, _Allocator> : private __vector_base_common<true> { public: @@ -2024,21 +2051,8 @@ public: typedef size_type __storage_type; typedef __bit_iterator<vector, false> pointer; typedef __bit_iterator<vector, true> const_pointer; -#ifdef _LIBCPP_DEBUG - typedef __debug_iter<vector, pointer> iterator; - typedef __debug_iter<vector, const_pointer> const_iterator; - - friend class __debug_iter<vector, pointer>; - friend class __debug_iter<vector, const_pointer>; - - pair<iterator*, const_iterator*> __iterator_list_; - - _LIBCPP_INLINE_VISIBILITY iterator*& __get_iterator_list(iterator*) {return __iterator_list_.first;} - _LIBCPP_INLINE_VISIBILITY const_iterator*& __get_iterator_list(const_iterator*) {return __iterator_list_.second;} -#else // _LIBCPP_DEBUG typedef pointer iterator; typedef const_pointer const_iterator; -#endif // _LIBCPP_DEBUG typedef _VSTD::reverse_iterator<iterator> reverse_iterator; typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator; @@ -2090,6 +2104,9 @@ public: _LIBCPP_INLINE_VISIBILITY explicit vector(const allocator_type& __a); ~vector(); explicit vector(size_type __n); +#if _LIBCPP_STD_VER > 11 + explicit vector(size_type __n, const allocator_type& __a); +#endif vector(size_type __n, const value_type& __v); vector(size_type __n, const value_type& __v, const allocator_type& __a); template <class _InputIterator> @@ -2221,8 +2238,20 @@ public: _LIBCPP_INLINE_VISIBILITY const_reference back() const {return __make_ref(__size_ - 1);} void push_back(const value_type& __x); +#if _LIBCPP_STD_VER > 11 + template <class... _Args> + _LIBCPP_INLINE_VISIBILITY void emplace_back(_Args&&... __args) + { push_back ( value_type ( _VSTD::forward<_Args>(__args)... )); } +#endif + _LIBCPP_INLINE_VISIBILITY void pop_back() {--__size_;} +#if _LIBCPP_STD_VER > 11 + template <class... _Args> + _LIBCPP_INLINE_VISIBILITY iterator emplace(const_iterator position, _Args&&... __args) + { return insert ( position, value_type ( _VSTD::forward<_Args>(__args)... )); } +#endif + iterator insert(const_iterator __position, const value_type& __x); iterator insert(const_iterator __position, size_type __n, const value_type& __x); iterator insert(const_iterator __position, size_type __n, const_reference __x); @@ -2267,7 +2296,7 @@ private: void allocate(size_type __n); void deallocate() _NOEXCEPT; _LIBCPP_INLINE_VISIBILITY - static size_type __align(size_type __new_size) _NOEXCEPT + static size_type __align_it(size_type __new_size) _NOEXCEPT {return __new_size + (__bits_per_word-1) & ~(__bits_per_word-1);}; _LIBCPP_INLINE_VISIBILITY size_type __recommend(size_type __new_size) const; _LIBCPP_INLINE_VISIBILITY void __construct_at_end(size_type __n, bool __x); @@ -2285,14 +2314,6 @@ private: _LIBCPP_INLINE_VISIBILITY const_reference __make_ref(size_type __pos) const _NOEXCEPT {return const_reference(__begin_ + __pos / __bits_per_word, __storage_type(1) << __pos % __bits_per_word);} -#ifdef _LIBCPP_DEBUG - _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_type __pos) - {return iterator(this, pointer(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word)));} - _LIBCPP_INLINE_VISIBILITY const_iterator __make_iter(size_type __pos) const - {return const_iterator(this, const_pointer(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word)));} - _LIBCPP_INLINE_VISIBILITY iterator __const_iterator_cast(const_iterator __p) - {return iterator(this, pointer(const_cast<__storage_pointer>(__p.base().__seg_), __p.base().__ctz_));} -#else // _LIBCPP_DEBUG _LIBCPP_INLINE_VISIBILITY iterator __make_iter(size_type __pos) _NOEXCEPT {return iterator(__begin_ + __pos / __bits_per_word, static_cast<unsigned>(__pos % __bits_per_word));} @@ -2302,7 +2323,6 @@ private: _LIBCPP_INLINE_VISIBILITY iterator __const_iterator_cast(const_iterator __p) _NOEXCEPT {return begin() + (__p - cbegin());} -#endif // _LIBCPP_DEBUG _LIBCPP_INLINE_VISIBILITY void __copy_assign_alloc(const vector& __v) @@ -2369,20 +2389,14 @@ private: friend class __bit_iterator<vector, false>; friend class __bit_iterator<vector, true>; friend struct __bit_array<vector>; - friend struct _LIBCPP_TYPE_VIS hash<vector>; + friend struct _LIBCPP_TYPE_VIS_ONLY hash<vector>; }; template <class _Allocator> -#ifndef _LIBCPP_DEBUG -_LIBCPP_INLINE_VISIBILITY inline -#endif +inline _LIBCPP_INLINE_VISIBILITY void vector<bool, _Allocator>::__invalidate_all_iterators() { -#ifdef _LIBCPP_DEBUG - iterator::__remove_all(this); - const_iterator::__remove_all(this); -#endif // _LIBCPP_DEBUG } // Allocate space for __n objects @@ -2430,7 +2444,7 @@ vector<bool, _Allocator>::max_size() const _NOEXCEPT // Precondition: __new_size > capacity() template <class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<bool, _Allocator>::size_type vector<bool, _Allocator>::__recommend(size_type __new_size) const { @@ -2440,7 +2454,7 @@ vector<bool, _Allocator>::__recommend(size_type __new_size) const const size_type __cap = capacity(); if (__cap >= __ms / 2) return __ms; - return _VSTD::max(2*__cap, __align(__new_size)); + return _VSTD::max(2*__cap, __align_it(__new_size)); } // Default constructs __n objects starting at __end_ @@ -2448,7 +2462,7 @@ vector<bool, _Allocator>::__recommend(size_type __new_size) const // Precondition: size() + __n <= capacity() // Postcondition: size() == size() + __n template <class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void vector<bool, _Allocator>::__construct_at_end(size_type __n, bool __x) { @@ -2472,7 +2486,7 @@ vector<bool, _Allocator>::__construct_at_end(_ForwardIterator __first, _ForwardI } template <class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector() _NOEXCEPT_(is_nothrow_default_constructible<allocator_type>::value) : __begin_(nullptr), @@ -2482,7 +2496,7 @@ vector<bool, _Allocator>::vector() } template <class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(const allocator_type& __a) : __begin_(nullptr), __size_(0), @@ -2503,6 +2517,21 @@ vector<bool, _Allocator>::vector(size_type __n) } } +#if _LIBCPP_STD_VER > 11 +template <class _Allocator> +vector<bool, _Allocator>::vector(size_type __n, const allocator_type& __a) + : __begin_(nullptr), + __size_(0), + __cap_alloc_(0, static_cast<__storage_allocator>(__a)) +{ + if (__n > 0) + { + allocate(__n); + __construct_at_end(__n, false); + } +} +#endif + template <class _Allocator> vector<bool, _Allocator>::vector(size_type __n, const value_type& __x) : __begin_(nullptr), @@ -2652,9 +2681,7 @@ vector<bool, _Allocator>::~vector() { if (__begin_ != nullptr) __storage_traits::deallocate(__alloc(), __begin_, __cap()); -#ifdef _LIBCPP_DEBUG __invalidate_all_iterators(); -#endif } template <class _Allocator> @@ -2707,7 +2734,7 @@ vector<bool, _Allocator>::operator=(const vector& __v) #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES template <class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>::vector(vector&& __v) _NOEXCEPT_(is_nothrow_move_constructible<allocator_type>::value) : __begin_(__v.__begin_), @@ -2741,7 +2768,7 @@ vector<bool, _Allocator>::vector(vector&& __v, const allocator_type& __a) } template <class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY vector<bool, _Allocator>& vector<bool, _Allocator>::operator=(vector&& __v) _NOEXCEPT_( @@ -3028,7 +3055,7 @@ vector<bool, _Allocator>::insert(const_iterator __position, _ForwardIterator __f } template <class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY typename vector<bool, _Allocator>::iterator vector<bool, _Allocator>::erase(const_iterator __position) { @@ -3059,10 +3086,6 @@ vector<bool, _Allocator>::swap(vector& __x) _VSTD::swap(this->__size_, __x.__size_); _VSTD::swap(this->__cap(), __x.__cap()); __swap_alloc(this->__alloc(), __x.__alloc()); -#ifdef _LIBCPP_DEBUG - iterator::swap(this, &__x); - const_iterator::swap(this, &__x); -#endif // _LIBCPP_DEBUG } template <class _Allocator> @@ -3152,7 +3175,7 @@ vector<bool, _Allocator>::__hash_code() const _NOEXCEPT } template <class _Allocator> -struct _LIBCPP_TYPE_VIS hash<vector<bool, _Allocator> > +struct _LIBCPP_TYPE_VIS_ONLY hash<vector<bool, _Allocator> > : public unary_function<vector<bool, _Allocator>, size_t> { _LIBCPP_INLINE_VISIBILITY @@ -3161,7 +3184,7 @@ struct _LIBCPP_TYPE_VIS hash<vector<bool, _Allocator> > }; template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { @@ -3170,7 +3193,7 @@ operator==(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __ } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { @@ -3178,7 +3201,7 @@ operator!=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __ } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { @@ -3186,7 +3209,7 @@ operator< (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __ } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { @@ -3194,7 +3217,7 @@ operator> (const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __ } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { @@ -3202,7 +3225,7 @@ operator>=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __ } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY bool operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __y) { @@ -3210,7 +3233,7 @@ operator<=(const vector<_Tp, _Allocator>& __x, const vector<_Tp, _Allocator>& __ } template <class _Tp, class _Allocator> -_LIBCPP_INLINE_VISIBILITY inline +inline _LIBCPP_INLINE_VISIBILITY void swap(vector<_Tp, _Allocator>& __x, vector<_Tp, _Allocator>& __y) _NOEXCEPT_(_NOEXCEPT_(__x.swap(__y))) diff --git a/system/lib/libcxx/CREDITS.TXT b/system/lib/libcxx/CREDITS.TXT index 5e4d14ec..368b526f 100644 --- a/system/lib/libcxx/CREDITS.TXT +++ b/system/lib/libcxx/CREDITS.TXT @@ -31,7 +31,7 @@ D: FreeBSD and Solaris ports, libcxxrt support, some atomics work. N: Marshall Clow E: mclow.lists@gmail.com E: marshall@idio.com -D: Minor patches and bug fixes. +D: C++14 support, patches and bug fixes. N: Bill Fisher E: william.w.fisher@gmail.com @@ -76,6 +76,10 @@ N: Bjorn Reese E: breese@users.sourceforge.net D: Initial regex prototype +N: Nico Rieck +E: nico.rieck@gmail.com +D: Windows fixes + N: Jonathan Sauer D: Minor patches, mostly related to constexpr @@ -105,6 +109,10 @@ N: Zhang Xiongpang E: zhangxiongpang@gmail.com D: Minor patches and bug fixes. +N: Xing Xue +E: xingxue@ca.ibm.com +D: AIX port + N: Zhihao Yuan E: lichray@gmail.com D: Standard compatibility fixes. diff --git a/system/lib/libcxx/algorithm.cpp b/system/lib/libcxx/algorithm.cpp index 6d5cf7c0..10c4c331 100644 --- a/system/lib/libcxx/algorithm.cpp +++ b/system/lib/libcxx/algorithm.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; #include "algorithm" #include "random" #include "mutex" diff --git a/system/lib/libcxx/debug.cpp b/system/lib/libcxx/debug.cpp index c9b09b7a..d0e86795 100644 --- a/system/lib/libcxx/debug.cpp +++ b/system/lib/libcxx/debug.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#define _LIBCPP_DEBUG2 1 +#define _LIBCPP_DEBUG 1 #include "__config" #include "__debug" #include "functional" @@ -118,20 +118,19 @@ void __libcpp_db::__insert_ic(void* __i, const void* __c) { WLock _(mut()); - __i_node* i = __insert_iterator(__i); - const char* errmsg = - "Container constructed in a translation unit with debug mode disabled." - " But it is being used in a translation unit with debug mode enabled." - " Enable it in the other translation unit with #define _LIBCPP_DEBUG2 1"; - _LIBCPP_ASSERT(__cbeg_ != __cend_, errmsg); + if (__cbeg_ == __cend_) + return; size_t hc = hash<const void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); __c_node* c = __cbeg_[hc]; - _LIBCPP_ASSERT(c != nullptr, errmsg); + if (c == nullptr) + return; while (c->__c_ != __c) { c = c->__next_; - _LIBCPP_ASSERT(c != nullptr, errmsg); + if (c == nullptr) + return; } + __i_node* i = __insert_iterator(__i); c->__add(i); i->__c_ = c; } @@ -217,18 +216,23 @@ void __libcpp_db::__invalidate_all(void* __c) { WLock _(mut()); - size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); - __c_node* p = __cbeg_[hc]; - _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __invalidate_all A"); - while (p->__c_ != __c) - { - p = p->__next_; - _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __invalidate_all B"); - } - while (p->end_ != p->beg_) + if (__cend_ != __cbeg_) { - --p->end_; - (*p->end_)->__c_ = nullptr; + size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); + __c_node* p = __cbeg_[hc]; + if (p == nullptr) + return; + while (p->__c_ != __c) + { + p = p->__next_; + if (p == nullptr) + return; + } + while (p->end_ != p->beg_) + { + --p->end_; + (*p->end_)->__c_ = nullptr; + } } } @@ -236,13 +240,26 @@ __c_node* __libcpp_db::__find_c_and_lock(void* __c) const { mut().lock(); + if (__cend_ == __cbeg_) + { + mut().unlock(); + return nullptr; + } size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); __c_node* p = __cbeg_[hc]; - _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __find_c_and_lock A"); + if (p == nullptr) + { + mut().unlock(); + return nullptr; + } while (p->__c_ != __c) { p = p->__next_; - _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __find_c_and_lock B"); + if (p == nullptr) + { + mut().unlock(); + return nullptr; + } } return p; } @@ -271,28 +288,35 @@ void __libcpp_db::__erase_c(void* __c) { WLock _(mut()); - size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); - __c_node* p = __cbeg_[hc]; - __c_node* q = nullptr; - _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c A"); - while (p->__c_ != __c) + if (__cend_ != __cbeg_) { - q = p; - p = p->__next_; - _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c B"); - } - if (q == nullptr) - __cbeg_[hc] = p->__next_; - else - q->__next_ = p->__next_; - while (p->end_ != p->beg_) - { - --p->end_; - (*p->end_)->__c_ = nullptr; + size_t hc = hash<void*>()(__c) % static_cast<size_t>(__cend_ - __cbeg_); + __c_node* p = __cbeg_[hc]; + if (p == nullptr) + return; + __c_node* q = nullptr; + _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c A"); + while (p->__c_ != __c) + { + q = p; + p = p->__next_; + if (p == nullptr) + return; + _LIBCPP_ASSERT(p != nullptr, "debug mode internal logic error __erase_c B"); + } + if (q == nullptr) + __cbeg_[hc] = p->__next_; + else + q->__next_ = p->__next_; + while (p->end_ != p->beg_) + { + --p->end_; + (*p->end_)->__c_ = nullptr; + } + free(p->beg_); + free(p); + --__csz_; } - free(p->beg_); - free(p); - --__csz_; } void diff --git a/system/lib/libcxx/exception.cpp b/system/lib/libcxx/exception.cpp index 3487bd8b..83f6fd19 100644 --- a/system/lib/libcxx/exception.cpp +++ b/system/lib/libcxx/exception.cpp @@ -10,6 +10,7 @@ #include <stdio.h> #include "exception" +#include "new" #ifndef __has_include #define __has_include(inc) 0 @@ -90,14 +91,14 @@ terminate() _NOEXCEPT (*get_terminate())(); // handler should not return printf("terminate_handler unexpectedly returned\n"); - ::abort (); + ::abort(); #ifndef _LIBCPP_NO_EXCEPTIONS } catch (...) { // handler should not throw exception printf("terminate_handler unexpectedly threw an exception\n"); - ::abort (); + ::abort(); } #endif // _LIBCPP_NO_EXCEPTIONS } @@ -111,12 +112,17 @@ bool uncaught_exception() _NOEXCEPT // on Darwin, there is a helper function so __cxa_get_globals is private return __cxa_uncaught_exception(); #else // __APPLE__ - #warning uncaught_exception not yet implemented +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("uncaught_exception not yet implemented") +# else +# warning uncaught_exception not yet implemented +# endif printf("uncaught_exception not yet implemented\n"); ::abort(); #endif // __APPLE__ } + #ifndef _LIBCPPABI_VERSION exception::~exception() _NOEXCEPT @@ -143,16 +149,50 @@ const char* bad_exception::what() const _NOEXCEPT #endif +#if defined(__GLIBCXX__) + +// libsupc++ does not implement the dependent EH ABI and the functionality +// it uses to implement std::exception_ptr (which it declares as an alias of +// std::__exception_ptr::exception_ptr) is not directly exported to clients. So +// we have little choice but to hijack std::__exception_ptr::exception_ptr's +// (which fortunately has the same layout as our std::exception_ptr) copy +// constructor, assignment operator and destructor (which are part of its +// stable ABI), and its rethrow_exception(std::__exception_ptr::exception_ptr) +// function. + +namespace __exception_ptr +{ + +struct exception_ptr +{ + void* __ptr_; + + exception_ptr(const exception_ptr&) _NOEXCEPT; + exception_ptr& operator=(const exception_ptr&) _NOEXCEPT; + ~exception_ptr() _NOEXCEPT; +}; + +} + +_LIBCPP_NORETURN void rethrow_exception(__exception_ptr::exception_ptr); + +#endif exception_ptr::~exception_ptr() _NOEXCEPT { #if HAVE_DEPENDENT_EH_ABI __cxa_decrement_exception_refcount(__ptr_); +#elif defined(__GLIBCXX__) + reinterpret_cast<__exception_ptr::exception_ptr*>(this)->~exception_ptr(); #else - #warning exception_ptr not yet implemented +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("exception_ptr not yet implemented") +# else +# warning exception_ptr not yet implemented +# endif printf("exception_ptr not yet implemented\n"); ::abort(); -#endif // __APPLE__ +#endif } exception_ptr::exception_ptr(const exception_ptr& other) _NOEXCEPT @@ -160,11 +200,18 @@ exception_ptr::exception_ptr(const exception_ptr& other) _NOEXCEPT { #if HAVE_DEPENDENT_EH_ABI __cxa_increment_exception_refcount(__ptr_); +#elif defined(__GLIBCXX__) + new (reinterpret_cast<void*>(this)) __exception_ptr::exception_ptr( + reinterpret_cast<const __exception_ptr::exception_ptr&>(other)); #else - #warning exception_ptr not yet implemented +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("exception_ptr not yet implemented") +# else +# warning exception_ptr not yet implemented +# endif printf("exception_ptr not yet implemented\n"); ::abort(); -#endif // __APPLE__ +#endif } exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT @@ -177,11 +224,19 @@ exception_ptr& exception_ptr::operator=(const exception_ptr& other) _NOEXCEPT __ptr_ = other.__ptr_; } return *this; -#else // __APPLE__ - #warning exception_ptr not yet implemented +#elif defined(__GLIBCXX__) + *reinterpret_cast<__exception_ptr::exception_ptr*>(this) = + reinterpret_cast<const __exception_ptr::exception_ptr&>(other); + return *this; +#else +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("exception_ptr not yet implemented") +# else +# warning exception_ptr not yet implemented +# endif printf("exception_ptr not yet implemented\n"); ::abort(); -#endif // __APPLE__ +#endif } nested_exception::nested_exception() _NOEXCEPT @@ -189,10 +244,14 @@ nested_exception::nested_exception() _NOEXCEPT { } +#if !defined(__GLIBCXX__) + nested_exception::~nested_exception() _NOEXCEPT { } +#endif + _LIBCPP_NORETURN void nested_exception::rethrow_nested() const @@ -202,6 +261,7 @@ nested_exception::rethrow_nested() const rethrow_exception(__ptr_); } +#if !defined(__GLIBCXX__) exception_ptr current_exception() _NOEXCEPT { @@ -212,13 +272,19 @@ exception_ptr current_exception() _NOEXCEPT exception_ptr ptr; ptr.__ptr_ = __cxa_current_primary_exception(); return ptr; -#else // __APPLE__ - #warning exception_ptr not yet implemented +#else +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING( "exception_ptr not yet implemented" ) +# else +# warning exception_ptr not yet implemented +# endif printf("exception_ptr not yet implemented\n"); ::abort(); -#endif // __APPLE__ +#endif } +#endif // !__GLIBCXX__ + _LIBCPP_NORETURN void rethrow_exception(exception_ptr p) { @@ -226,10 +292,16 @@ void rethrow_exception(exception_ptr p) __cxa_rethrow_primary_exception(p.__ptr_); // if p.__ptr_ is NULL, above returns so we terminate terminate(); -#else // __APPLE__ - #warning exception_ptr not yet implemented +#elif defined(__GLIBCXX__) + rethrow_exception(reinterpret_cast<__exception_ptr::exception_ptr&>(p)); +#else +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("exception_ptr not yet implemented") +# else +# warning exception_ptr not yet implemented +# endif printf("exception_ptr not yet implemented\n"); ::abort(); -#endif // __APPLE__ +#endif } } // std diff --git a/system/lib/libcxx/future.cpp b/system/lib/libcxx/future.cpp index 7d9a5b5d..70919ab7 100644 --- a/system/lib/libcxx/future.cpp +++ b/system/lib/libcxx/future.cpp @@ -26,11 +26,15 @@ __future_error_category::name() const _NOEXCEPT return "future"; } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wswitch" + string __future_error_category::message(int ev) const { switch (static_cast<future_errc>(ev)) { + case future_errc(0): // For backwards compatibility with C++11 (LWG 2056) case future_errc::broken_promise: return string("The associated promise has been destructed prior " "to the associated state becoming ready."); @@ -46,6 +50,8 @@ __future_error_category::message(int ev) const return string("unspecified future_errc value\n"); } +#pragma clang diagnostic pop + const error_category& future_category() _NOEXCEPT { diff --git a/system/lib/libcxx/ios.cpp b/system/lib/libcxx/ios.cpp index 732a61bb..004d3183 100644 --- a/system/lib/libcxx/ios.cpp +++ b/system/lib/libcxx/ios.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; + #include "ios" #include "streambuf" #include "istream" @@ -61,7 +63,7 @@ __iostream_category::message(int ev) const } const error_category& -iostream_category() +iostream_category() _NOEXCEPT { static __iostream_category s; return s; @@ -147,8 +149,11 @@ ios_base::getloc() const } // xalloc - +#if __has_feature(cxx_atomic) && !defined(__EMSCRIPTEN__) +atomic<int> ios_base::__xindex_ = ATOMIC_VAR_INIT(0); +#else int ios_base::__xindex_ = 0; +#endif int ios_base::xalloc() diff --git a/system/lib/libcxx/iostream.cpp b/system/lib/libcxx/iostream.cpp index f413681f..7102e438 100644 --- a/system/lib/libcxx/iostream.cpp +++ b/system/lib/libcxx/iostream.cpp @@ -22,14 +22,14 @@ _ALIGNAS_TYPE (__stdinbuf<wchar_t> ) static char __wcin [sizeof(__stdinbuf <wcha _ALIGNAS_TYPE (__stdoutbuf<wchar_t>) static char __wcout[sizeof(__stdoutbuf<wchar_t>)]; _ALIGNAS_TYPE (__stdoutbuf<wchar_t>) static char __wcerr[sizeof(__stdoutbuf<wchar_t>)]; -_ALIGNAS_TYPE (istream) char cin [sizeof(istream)]; -_ALIGNAS_TYPE (ostream) char cout[sizeof(ostream)]; -_ALIGNAS_TYPE (ostream) char cerr[sizeof(ostream)]; -_ALIGNAS_TYPE (ostream) char clog[sizeof(ostream)]; -_ALIGNAS_TYPE (wistream) char wcin [sizeof(wistream)]; -_ALIGNAS_TYPE (wostream) char wcout[sizeof(wostream)]; -_ALIGNAS_TYPE (wostream) char wcerr[sizeof(wostream)]; -_ALIGNAS_TYPE (wostream) char wclog[sizeof(wostream)]; +_ALIGNAS_TYPE (istream) _LIBCPP_FUNC_VIS char cin [sizeof(istream)]; +_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cout[sizeof(ostream)]; +_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char cerr[sizeof(ostream)]; +_ALIGNAS_TYPE (ostream) _LIBCPP_FUNC_VIS char clog[sizeof(ostream)]; +_ALIGNAS_TYPE (wistream) _LIBCPP_FUNC_VIS char wcin [sizeof(wistream)]; +_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcout[sizeof(wostream)]; +_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wcerr[sizeof(wostream)]; +_ALIGNAS_TYPE (wostream) _LIBCPP_FUNC_VIS char wclog[sizeof(wostream)]; ios_base::Init __start_std_streams; diff --git a/system/lib/libcxx/locale.cpp b/system/lib/libcxx/locale.cpp index ad64668f..a326323a 100644 --- a/system/lib/libcxx/locale.cpp +++ b/system/lib/libcxx/locale.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; + // On Solaris, we need to define something to make the C99 parts of localeconv // visible. #ifdef __sun__ @@ -26,7 +28,7 @@ #include "cstring" #include "cwctype" #include "__sso_allocator" -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) #include <support/win32/locale_win32.h> #else // _LIBCPP_MSVCRT #include <langinfo.h> @@ -36,7 +38,9 @@ // On Linux, wint_t and wchar_t have different signed-ness, and this causes // lots of noise in the build log, but no bugs that I know of. +#if defined(__clang__) #pragma clang diagnostic ignored "-Wsign-conversion" +#endif _LIBCPP_BEGIN_NAMESPACE_STD @@ -107,6 +111,11 @@ countof(const T * const begin, const T * const end) } +#if defined(_AIX) +// Set priority to INT_MIN + 256 + 150 +# pragma priority ( -2147483242 ) +#endif + const locale::category locale::none; const locale::category locale::collate; const locale::category locale::ctype; @@ -116,14 +125,23 @@ const locale::category locale::time; const locale::category locale::messages; const locale::category locale::all; +#if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wpadded" +#endif class _LIBCPP_HIDDEN locale::__imp : public facet { enum {N = 28}; +#if defined(_LIBCPP_MSVC) +// FIXME: MSVC doesn't support aligned parameters by value. +// I can't get the __sso_allocator to work here +// for MSVC I think for this reason. + vector<facet*> facets_; +#else vector<facet*, __sso_allocator<facet*, N> > facets_; +#endif string name_; public: explicit __imp(size_t refs = 0); @@ -147,7 +165,9 @@ private: template <class F> void install_from(const __imp& other); }; +#if defined(__clang__) #pragma clang diagnostic pop +#endif locale::__imp::__imp(size_t refs) : facet(refs), @@ -757,7 +777,7 @@ ctype<wchar_t>::~ctype() bool ctype<wchar_t>::do_is(mask m, char_type c) const { - return isascii(c) ? ctype<char>::classic_table()[c] & m : false; + return isascii(c) ? (ctype<char>::classic_table()[c] & m) != 0 : false; } const wchar_t* @@ -1009,12 +1029,14 @@ ctype<char>::classic_table() _NOEXCEPT return __cloc()->__ctype_b; #elif __sun__ return __ctype_mask; -#elif defined(_LIBCPP_MSVCRT) +#elif defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) return _ctype+1; // internal ctype mask table defined in msvcrt.dll // This is assumed to be safe, which is a nonsense assumption because we're // going to end up dereferencing it later... #elif defined(__EMSCRIPTEN__) return *__ctype_b_loc(); +#elif defined(_AIX) + return (const unsigned long *)__lc_ctype_ptr->obj->mask; #else // Platform not supported: abort so the person doing the port knows what to // fix @@ -4350,7 +4372,7 @@ __num_put_base::__format_float(char* __fmtp, const char* __len, if (__flags & ios_base::showpoint) *__fmtp++ = '#'; ios_base::fmtflags floatfield = __flags & ios_base::floatfield; - bool uppercase = __flags & ios_base::uppercase; + bool uppercase = (__flags & ios_base::uppercase) != 0; if (floatfield == (ios_base::fixed | ios_base::scientific)) specify_precision = false; else @@ -4681,9 +4703,12 @@ __time_get::~__time_get() { freelocale(__loc_); } - +#if defined(__clang__) #pragma clang diagnostic ignored "-Wmissing-field-initializers" +#endif +#if defined(__GNUG__) #pragma GCC diagnostic ignored "-Wmissing-field-initializers" +#endif template <> string @@ -4829,7 +4854,9 @@ __time_get_storage<char>::__analyze(char fmt, const ctype<char>& ct) return result; } +#if defined(__clang__) #pragma clang diagnostic ignored "-Wmissing-braces" +#endif template <> wstring @@ -5848,7 +5875,7 @@ moneypunct_byname<char, true>::init(const char* nm) __frac_digits_ = lc->int_frac_digits; else __frac_digits_ = base::do_frac_digits(); -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) if (lc->p_sign_posn == 0) #else // _LIBCPP_MSVCRT if (lc->int_p_sign_posn == 0) @@ -5856,7 +5883,7 @@ moneypunct_byname<char, true>::init(const char* nm) __positive_sign_ = "()"; else __positive_sign_ = lc->positive_sign; -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) if(lc->n_sign_posn == 0) #else // _LIBCPP_MSVCRT if (lc->int_n_sign_posn == 0) @@ -5868,7 +5895,7 @@ moneypunct_byname<char, true>::init(const char* nm) // the same places in curr_symbol since there's no way to // represent anything else. string_type __dummy_curr_symbol = __curr_symbol_; -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) __init_pat(__pos_format_, __dummy_curr_symbol, true, lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, ' '); __init_pat(__neg_format_, __curr_symbol_, true, @@ -6007,7 +6034,7 @@ moneypunct_byname<wchar_t, true>::init(const char* nm) __frac_digits_ = lc->int_frac_digits; else __frac_digits_ = base::do_frac_digits(); -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) if (lc->p_sign_posn == 0) #else // _LIBCPP_MSVCRT if (lc->int_p_sign_posn == 0) @@ -6027,7 +6054,7 @@ moneypunct_byname<wchar_t, true>::init(const char* nm) wbe = wbuf + j; __positive_sign_.assign(wbuf, wbe); } -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) if (lc->n_sign_posn == 0) #else // _LIBCPP_MSVCRT if (lc->int_n_sign_posn == 0) @@ -6051,7 +6078,7 @@ moneypunct_byname<wchar_t, true>::init(const char* nm) // the same places in curr_symbol since there's no way to // represent anything else. string_type __dummy_curr_symbol = __curr_symbol_; -#ifdef _LIBCPP_MSVCRT +#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__) __init_pat(__pos_format_, __dummy_curr_symbol, true, lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, L' '); __init_pat(__neg_format_, __curr_symbol_, true, diff --git a/system/lib/libcxx/mutex.cpp b/system/lib/libcxx/mutex.cpp index 42195aa8..07678978 100644 --- a/system/lib/libcxx/mutex.cpp +++ b/system/lib/libcxx/mutex.cpp @@ -42,6 +42,7 @@ void mutex::unlock() _NOEXCEPT { int ec = pthread_mutex_unlock(&__m_); + (void)ec; assert(ec == 0); } @@ -79,6 +80,7 @@ fail: recursive_mutex::~recursive_mutex() { int e = pthread_mutex_destroy(&__m_); + (void)e; assert(e == 0); } @@ -94,6 +96,7 @@ void recursive_mutex::unlock() _NOEXCEPT { int e = pthread_mutex_unlock(&__m_); + (void)e; assert(e == 0); } diff --git a/system/lib/libcxx/new.cpp b/system/lib/libcxx/new.cpp index b23a516f..fa0331a8 100644 --- a/system/lib/libcxx/new.cpp +++ b/system/lib/libcxx/new.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_BUILDING_NEW + #include <stdlib.h> #include "new" @@ -28,16 +30,18 @@ #if defined(LIBCXXRT) || __has_include(<cxxabi.h>) #include <cxxabi.h> #endif // __has_include(<cxxabi.h>) - #ifndef _LIBCPPABI_VERSION + #if !defined(_LIBCPPABI_VERSION) && !defined(__GLIBCXX__) static std::new_handler __new_handler; #endif // _LIBCPPABI_VERSION #endif +#ifndef __GLIBCXX__ + // Implement all new and delete operators as weak definitions // in this shared library, so that they can be overriden by programs // that define non-weak copies of the functions. -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void * operator new(std::size_t size) #if !__has_feature(cxx_noexcept) @@ -64,7 +68,7 @@ operator new(std::size_t size) return p; } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void* operator new(size_t size, const std::nothrow_t&) _NOEXCEPT { @@ -83,7 +87,7 @@ operator new(size_t size, const std::nothrow_t&) _NOEXCEPT return p; } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void* operator new[](size_t size) #if !__has_feature(cxx_noexcept) @@ -93,7 +97,7 @@ operator new[](size_t size) return ::operator new(size); } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void* operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT { @@ -112,7 +116,7 @@ operator new[](size_t size, const std::nothrow_t&) _NOEXCEPT return p; } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void operator delete(void* ptr) _NOEXCEPT { @@ -120,34 +124,40 @@ operator delete(void* ptr) _NOEXCEPT ::free(ptr); } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void operator delete(void* ptr, const std::nothrow_t&) _NOEXCEPT { ::operator delete(ptr); } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void operator delete[] (void* ptr) _NOEXCEPT { ::operator delete (ptr); } -__attribute__((__weak__, __visibility__("default"))) +_LIBCPP_WEAK _LIBCPP_NEW_DELETE_VIS void operator delete[] (void* ptr, const std::nothrow_t&) _NOEXCEPT { ::operator delete[](ptr); } +#endif // !__GLIBCXX__ + namespace std { +#ifndef __GLIBCXX__ const nothrow_t nothrow = {}; +#endif #ifndef _LIBCPPABI_VERSION +#ifndef __GLIBCXX__ + new_handler set_new_handler(new_handler handler) _NOEXCEPT { @@ -160,12 +170,16 @@ get_new_handler() _NOEXCEPT return __sync_fetch_and_add(&__new_handler, (new_handler)0); } +#endif // !__GLIBCXX__ + #ifndef LIBCXXRT bad_alloc::bad_alloc() _NOEXCEPT { } +#ifndef __GLIBCXX__ + bad_alloc::~bad_alloc() _NOEXCEPT { } @@ -176,6 +190,8 @@ bad_alloc::what() const _NOEXCEPT return "std::bad_alloc"; } +#endif // !__GLIBCXX__ + #endif //LIBCXXRT bad_array_new_length::bad_array_new_length() _NOEXCEPT @@ -187,12 +203,28 @@ bad_array_new_length::~bad_array_new_length() _NOEXCEPT } const char* +bad_array_length::what() const _NOEXCEPT +{ + return "bad_array_length"; +} + +bad_array_length::bad_array_length() _NOEXCEPT +{ +} + +bad_array_length::~bad_array_length() _NOEXCEPT +{ +} + +const char* bad_array_new_length::what() const _NOEXCEPT { return "bad_array_new_length"; } -#endif +#endif // _LIBCPPABI_VERSION + +#ifndef LIBSTDCXX void __throw_bad_alloc() @@ -202,4 +234,6 @@ __throw_bad_alloc() #endif } +#endif // !LIBSTDCXX + } // std diff --git a/system/lib/libcxx/optional.cpp b/system/lib/libcxx/optional.cpp new file mode 100644 index 00000000..fde071c9 --- /dev/null +++ b/system/lib/libcxx/optional.cpp @@ -0,0 +1,25 @@ +//===------------------------ optional.cpp --------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "optional" + +namespace std // purposefully not using versioning namespace +{ + +#ifdef _LIBCPP_HAS_NO_DEFAULTED_FUNCTIONS + +bad_optional_access::~bad_optional_access() _NOEXCEPT {} + +#else + +bad_optional_access::~bad_optional_access() _NOEXCEPT = default; + +#endif + +} // std diff --git a/system/lib/libcxx/random.cpp b/system/lib/libcxx/random.cpp index 97a40c50..47cdee40 100644 --- a/system/lib/libcxx/random.cpp +++ b/system/lib/libcxx/random.cpp @@ -7,6 +7,12 @@ // //===----------------------------------------------------------------------===// +#if defined(_WIN32) +// Must be defined before including stdlib.h to enable rand_s(). +#define _CRT_RAND_S +#include <stdio.h> +#endif + #include "random" #include "system_error" @@ -19,6 +25,25 @@ _LIBCPP_BEGIN_NAMESPACE_STD +#if defined(_WIN32) +random_device::random_device(const string&) +{ +} + +random_device::~random_device() +{ +} + +unsigned +random_device::operator()() +{ + unsigned r; + errno_t err = rand_s(&r); + if (err) + __throw_system_error(err, "random_device rand_s failed."); + return r; +} +#else random_device::random_device(const string& __token) : __f_(open(__token.c_str(), O_RDONLY)) { @@ -38,6 +63,7 @@ random_device::operator()() read(__f_, &r, sizeof(r)); return r; } +#endif // defined(_WIN32) double random_device::entropy() const _NOEXCEPT diff --git a/system/lib/libcxx/readme.txt b/system/lib/libcxx/readme.txt index 7687e5b2..ae8090fd 100644 --- a/system/lib/libcxx/readme.txt +++ b/system/lib/libcxx/readme.txt @@ -1 +1 @@ -These files are from libc++, svn revision 187959, 2013-08-08. +These files are from libc++, svn revision 194185, 2013-11-07. diff --git a/system/lib/libcxx/shared_mutex.cpp b/system/lib/libcxx/shared_mutex.cpp new file mode 100644 index 00000000..5fb22e44 --- /dev/null +++ b/system/lib/libcxx/shared_mutex.cpp @@ -0,0 +1,101 @@ +//===---------------------- shared_mutex.cpp ------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#define _LIBCPP_BUILDING_SHARED_MUTEX +#include "shared_mutex" + +_LIBCPP_BEGIN_NAMESPACE_STD + +shared_mutex::shared_mutex() + : __state_(0) +{ +} + +// Exclusive ownership + +void +shared_mutex::lock() +{ + unique_lock<mutex> lk(__mut_); + while (__state_ & __write_entered_) + __gate1_.wait(lk); + __state_ |= __write_entered_; + while (__state_ & __n_readers_) + __gate2_.wait(lk); +} + +bool +shared_mutex::try_lock() +{ + unique_lock<mutex> lk(__mut_); + if (__state_ == 0) + { + __state_ = __write_entered_; + return true; + } + return false; +} + +void +shared_mutex::unlock() +{ + lock_guard<mutex> _(__mut_); + __state_ = 0; + __gate1_.notify_all(); +} + +// Shared ownership + +void +shared_mutex::lock_shared() +{ + unique_lock<mutex> lk(__mut_); + while ((__state_ & __write_entered_) || (__state_ & __n_readers_) == __n_readers_) + __gate1_.wait(lk); + unsigned num_readers = (__state_ & __n_readers_) + 1; + __state_ &= ~__n_readers_; + __state_ |= num_readers; +} + +bool +shared_mutex::try_lock_shared() +{ + unique_lock<mutex> lk(__mut_); + unsigned num_readers = __state_ & __n_readers_; + if (!(__state_ & __write_entered_) && num_readers != __n_readers_) + { + ++num_readers; + __state_ &= ~__n_readers_; + __state_ |= num_readers; + return true; + } + return false; +} + +void +shared_mutex::unlock_shared() +{ + lock_guard<mutex> _(__mut_); + unsigned num_readers = (__state_ & __n_readers_) - 1; + __state_ &= ~__n_readers_; + __state_ |= num_readers; + if (__state_ & __write_entered_) + { + if (num_readers == 0) + __gate2_.notify_one(); + } + else + { + if (num_readers == __n_readers_ - 1) + __gate1_.notify_one(); + } +} + + +_LIBCPP_END_NAMESPACE_STD diff --git a/system/lib/libcxx/stdexcept.cpp b/system/lib/libcxx/stdexcept.cpp index 8d25f3ee..a4207d60 100644 --- a/system/lib/libcxx/stdexcept.cpp +++ b/system/lib/libcxx/stdexcept.cpp @@ -28,7 +28,9 @@ // Note: optimize for size +#if ! defined(_LIBCPP_MSVC) #pragma GCC visibility push(hidden) +#endif namespace { @@ -47,9 +49,9 @@ private: count_t& count() const _NOEXCEPT {return (count_t&)(*(str_ - sizeof(count_t)));} public: explicit __libcpp_nmstr(const char* msg); - __libcpp_nmstr(const __libcpp_nmstr& s) _LIBCPP_CANTTHROW; - __libcpp_nmstr& operator=(const __libcpp_nmstr& s) _LIBCPP_CANTTHROW; - ~__libcpp_nmstr() _LIBCPP_CANTTHROW; + __libcpp_nmstr(const __libcpp_nmstr& s) _NOEXCEPT; + __libcpp_nmstr& operator=(const __libcpp_nmstr& s) _NOEXCEPT; + ~__libcpp_nmstr(); const char* c_str() const _NOEXCEPT {return str_;} }; @@ -65,14 +67,14 @@ __libcpp_nmstr::__libcpp_nmstr(const char* msg) } inline -__libcpp_nmstr::__libcpp_nmstr(const __libcpp_nmstr& s) +__libcpp_nmstr::__libcpp_nmstr(const __libcpp_nmstr& s) _NOEXCEPT : str_(s.str_) { __sync_add_and_fetch(&count(), 1); } __libcpp_nmstr& -__libcpp_nmstr::operator=(const __libcpp_nmstr& s) +__libcpp_nmstr::operator=(const __libcpp_nmstr& s) _NOEXCEPT { const char* p = str_; str_ = s.str_; @@ -91,7 +93,9 @@ __libcpp_nmstr::~__libcpp_nmstr() } +#if ! defined(_LIBCPP_MSVC) #pragma GCC visibility pop +#endif namespace std // purposefully not using versioning namespace { @@ -123,7 +127,7 @@ logic_error::operator=(const logic_error& le) _NOEXCEPT return *this; } -#ifndef _LIBCPPABI_VERSION +#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX) logic_error::~logic_error() _NOEXCEPT { @@ -167,7 +171,7 @@ runtime_error::operator=(const runtime_error& le) _NOEXCEPT return *this; } -#ifndef _LIBCPPABI_VERSION +#if !defined(_LIBCPPABI_VERSION) && !defined(LIBSTDCXX) runtime_error::~runtime_error() _NOEXCEPT { diff --git a/system/lib/libcxx/string.cpp b/system/lib/libcxx/string.cpp index 5a869116..fde52129 100644 --- a/system/lib/libcxx/string.cpp +++ b/system/lib/libcxx/string.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; + #include "string" #include "cstdlib" #include "cwchar" @@ -89,7 +91,7 @@ inline int as_integer(const string& func, const string& s, size_t* idx, int base ) { - // Use long as no Stantard string to integer exists. + // Use long as no Standard string to integer exists. long r = as_integer_helper<long>( func, s, idx, base, strtol ); if (r < numeric_limits<int>::min() || numeric_limits<int>::max() < r) throw_from_string_out_of_range(func); diff --git a/system/lib/libcxx/strstream.cpp b/system/lib/libcxx/strstream.cpp index 518422bd..c1965ea3 100644 --- a/system/lib/libcxx/strstream.cpp +++ b/system/lib/libcxx/strstream.cpp @@ -156,13 +156,13 @@ strstreambuf::overflow(int_type __c) { if ((__strmode_ & __dynamic) == 0 || (__strmode_ & __frozen) != 0) return int_type(EOF); - streamsize old_size = (epptr() ? epptr() : egptr()) - eback(); - streamsize new_size = max<streamsize>(__alsize_, 2*old_size); + size_t old_size = static_cast<size_t> ((epptr() ? epptr() : egptr()) - eback()); + size_t new_size = max<size_t>(static_cast<size_t>(__alsize_), 2*old_size); if (new_size == 0) new_size = __default_alsize; char* buf = nullptr; if (__palloc_) - buf = static_cast<char*>(__palloc_(static_cast<size_t>(new_size))); + buf = static_cast<char*>(__palloc_(new_size)); else buf = new char[new_size]; if (buf == nullptr) @@ -229,8 +229,8 @@ strstreambuf::pos_type strstreambuf::seekoff(off_type __off, ios_base::seekdir __way, ios_base::openmode __which) { off_type __p(-1); - bool pos_in = __which & ios::in; - bool pos_out = __which & ios::out; + bool pos_in = (__which & ios::in) != 0; + bool pos_out = (__which & ios::out) != 0; bool legal = false; switch (__way) { @@ -287,8 +287,8 @@ strstreambuf::pos_type strstreambuf::seekpos(pos_type __sp, ios_base::openmode __which) { off_type __p(-1); - bool pos_in = __which & ios::in; - bool pos_out = __which & ios::out; + bool pos_in = (__which & ios::in) != 0; + bool pos_out = (__which & ios::out) != 0; if (pos_in || pos_out) { if (!((pos_in && gptr() == nullptr) || (pos_out && pptr() == nullptr))) diff --git a/system/lib/libcxx/support/win32/locale_win32.cpp b/system/lib/libcxx/support/win32/locale_win32.cpp index a639ade4..1729d84a 100644 --- a/system/lib/libcxx/support/win32/locale_win32.cpp +++ b/system/lib/libcxx/support/win32/locale_win32.cpp @@ -8,9 +8,8 @@ // //===----------------------------------------------------------------------===// -#include "support/win32/locale_win32.h" +#include <locale> #include <cstdarg> // va_start, va_end -#include <cwchar> // mbstate_t // FIXME: base currently unused. Needs manual work to construct the new locale locale_t newlocale( int mask, const char * locale, locale_t /*base*/ ) @@ -34,38 +33,38 @@ lconv *localeconv_l( locale_t loc ) __locale_raii __current( uselocale(loc), uselocale ); return localeconv(); } -size_t mbrlen_l( const char *__restrict__ s, size_t n, - mbstate_t *__restrict__ ps, locale_t loc ) +size_t mbrlen_l( const char *__restrict s, size_t n, + mbstate_t *__restrict ps, locale_t loc ) { __locale_raii __current( uselocale(loc), uselocale ); return mbrlen( s, n, ps ); } -size_t mbsrtowcs_l( wchar_t *__restrict__ dst, const char **__restrict__ src, - size_t len, mbstate_t *__restrict__ ps, locale_t loc ) +size_t mbsrtowcs_l( wchar_t *__restrict dst, const char **__restrict src, + size_t len, mbstate_t *__restrict ps, locale_t loc ) { __locale_raii __current( uselocale(loc), uselocale ); return mbsrtowcs( dst, src, len, ps ); } -size_t wcrtomb_l( char *__restrict__ s, wchar_t wc, mbstate_t *__restrict__ ps, +size_t wcrtomb_l( char *__restrict s, wchar_t wc, mbstate_t *__restrict ps, locale_t loc ) { __locale_raii __current( uselocale(loc), uselocale ); return wcrtomb( s, wc, ps ); } -size_t mbrtowc_l( wchar_t *__restrict__ pwc, const char *__restrict__ s, - size_t n, mbstate_t *__restrict__ ps, locale_t loc ) +size_t mbrtowc_l( wchar_t *__restrict pwc, const char *__restrict s, + size_t n, mbstate_t *__restrict ps, locale_t loc ) { __locale_raii __current( uselocale(loc), uselocale ); return mbrtowc( pwc, s, n, ps ); } -size_t mbsnrtowcs_l( wchar_t *__restrict__ dst, const char **__restrict__ src, - size_t nms, size_t len, mbstate_t *__restrict__ ps, locale_t loc ) +size_t mbsnrtowcs_l( wchar_t *__restrict dst, const char **__restrict src, + size_t nms, size_t len, mbstate_t *__restrict ps, locale_t loc ) { __locale_raii __current( uselocale(loc), uselocale ); return mbsnrtowcs( dst, src, nms, len, ps ); } -size_t wcsnrtombs_l( char *__restrict__ dst, const wchar_t **__restrict__ src, - size_t nwc, size_t len, mbstate_t *__restrict__ ps, locale_t loc ) +size_t wcsnrtombs_l( char *__restrict dst, const wchar_t **__restrict src, + size_t nwc, size_t len, mbstate_t *__restrict ps, locale_t loc ) { __locale_raii __current( uselocale(loc), uselocale ); return wcsnrtombs( dst, src, nwc, len, ps ); diff --git a/system/lib/libcxx/support/win32/support.cpp b/system/lib/libcxx/support/win32/support.cpp index 4215a700..6ee31e0c 100644 --- a/system/lib/libcxx/support/win32/support.cpp +++ b/system/lib/libcxx/support/win32/support.cpp @@ -14,14 +14,7 @@ #include <cstdio> // vsprintf, vsnprintf #include <cstring> // strcpy, wcsncpy #include <cwchar> // mbstate_t -#include <memory> // unique_ptr -namespace { // Private - - struct free_deleter { - inline void operator()(char* p) { free(p); } - }; -} // Some of these functions aren't standard or if they conform, the name does not. int asprintf(char **sptr, const char *__restrict format, ...) @@ -29,44 +22,44 @@ int asprintf(char **sptr, const char *__restrict format, ...) va_list ap; va_start(ap, format); int result; -#ifndef _LIBCPP_NO_EXCEPTIONS - try { -#endif - result = vasprintf(sptr, format, ap); -#ifndef _LIBCPP_NO_EXCEPTIONS - } catch( ... ) { - va_end(ap); - throw; - } -#endif + result = vasprintf(sptr, format, ap); va_end(ap); return result; } -// Like sprintf, but when return value >= 0 it returns a pointer to a malloc'd string in *sptr. +// Like sprintf, but when return value >= 0 it returns +// a pointer to a malloc'd string in *sptr. // If return >= 0, use free to delete *sptr. int vasprintf( char **sptr, const char *__restrict format, va_list ap ) { *sptr = NULL; - int count = _vsnprintf( NULL, 0, format, ap ); // Query the buffer size required. - if( count >= 0 ) { - std::unique_ptr<char, free_deleter> p( static_cast<char*>(malloc(count+1)) ); - if ( ! p ) - return -1; - if ( vsnprintf( p.get(), count+1, format, ap ) == count ) // We should have used exactly what was required. - *sptr = p.release(); - else // Otherwise something is wrong, likely a bug in vsnprintf. If so free the memory and report the error. - return -1; // Pointer will get automaticlaly deleted. + // Query the count required. + int count = _vsnprintf( NULL, 0, format, ap ); + if (count < 0) + return count; + size_t buffer_size = static_cast<size_t>(count) + 1; + char* p = static_cast<char*>(malloc(buffer_size)); + if ( ! p ) + return -1; + // If we haven't used exactly what was required, something is wrong. + // Maybe bug in vsnprintf. Report the error and return. + if (_vsnprintf(p, buffer_size, format, ap) != count) { + free(p); + return -1; } - + // All good. This is returning memory to the caller not freeing it. + *sptr = p; return count; } -// Returns >= 0: the number of wide characters found in the multi byte sequence src (of src_size_bytes), -// that fit in the buffer dst (of max_dest_chars elements size). The count returned excludes the null terminator. -// When dst is NULL, no characters are copied and no "out" parameters are updated. +// Returns >= 0: the number of wide characters found in the +// multi byte sequence src (of src_size_bytes), that fit in the buffer dst +// (of max_dest_chars elements size). The count returned excludes the +// null terminator. When dst is NULL, no characters are copied +// and no "out" parameters are updated. // Returns (size_t) -1: an incomplete sequence encountered. -// Leaves *src pointing the next character to convert or NULL if a null character was converted from *src. +// Leaves *src pointing the next character to convert or NULL +// if a null character was converted from *src. size_t mbsnrtowcs( wchar_t *__restrict dst, const char **__restrict src, size_t src_size_bytes, size_t max_dest_chars, mbstate_t *__restrict ps ) { @@ -112,10 +105,13 @@ size_t mbsnrtowcs( wchar_t *__restrict dst, const char **__restrict src, } // Converts max_source_chars from the wide character buffer pointer to by *src, -// into the multi byte character sequence buffer stored at dst which must be dst_size_bytes bytes in size. -// Returns >= 0: the number of bytes in the sequence sequence converted frome *src, excluding the null terminator. +// into the multi byte character sequence buffer stored at dst which must be +// dst_size_bytes bytes in size. +// Returns >= 0: the number of bytes in the sequence sequence +// converted frome *src, excluding the null terminator. // Returns size_t(-1) if an error occurs, also sets errno. -// If dst is NULL dst_size_bytes is ignored and no bytes are copied to dst and no "out" parameters are updated. +// If dst is NULL dst_size_bytes is ignored and no bytes are copied to dst +// and no "out" parameters are updated. size_t wcsnrtombs( char *__restrict dst, const wchar_t **__restrict src, size_t max_source_chars, size_t dst_size_bytes, mbstate_t *__restrict ps ) { @@ -138,7 +134,8 @@ size_t wcsnrtombs( char *__restrict dst, const wchar_t **__restrict src, result = wcrtomb_s( &char_size, dst + dest_converted, dest_remaining, c, ps); else result = wcrtomb_s( &char_size, NULL, 0, c, ps); - // If result is zero there is no error and char_size contains the size of the multi-byte-sequence converted. + // If result is zero there is no error and char_size contains the + // size of the multi-byte-sequence converted. // Otherwise result indicates an errno type error. if ( result == no_error ) { if ( c == L'\0' ) { diff --git a/system/lib/libcxx/symbols b/system/lib/libcxx/symbols index 92a665d8..51368bce 100644 --- a/system/lib/libcxx/symbols +++ b/system/lib/libcxx/symbols @@ -235,27 +235,27 @@ W _ZNKSt3__113basic_ostreamIcNS_11char_traitsIcEEE6sentrycvbEv W _ZNKSt3__113basic_ostreamIwNS_11char_traitsIwEEE6sentrycvbEv T _ZNKSt3__113random_device7entropyEv - T _ZNKSt3__114__codecvt_utf8IDiE10do_unshiftER10_mbstate_tPcS4_RS4_ + T _ZNKSt3__114__codecvt_utf8IDiE10do_unshiftER11__mbstate_tPcS4_RS4_ T _ZNKSt3__114__codecvt_utf8IDiE11do_encodingEv T _ZNKSt3__114__codecvt_utf8IDiE13do_max_lengthEv T _ZNKSt3__114__codecvt_utf8IDiE16do_always_noconvEv - T _ZNKSt3__114__codecvt_utf8IDiE5do_inER10_mbstate_tPKcS5_RS5_PDiS7_RS7_ - T _ZNKSt3__114__codecvt_utf8IDiE6do_outER10_mbstate_tPKDiS5_RS5_PcS7_RS7_ - T _ZNKSt3__114__codecvt_utf8IDiE9do_lengthER10_mbstate_tPKcS5_j - T _ZNKSt3__114__codecvt_utf8IDsE10do_unshiftER10_mbstate_tPcS4_RS4_ + T _ZNKSt3__114__codecvt_utf8IDiE5do_inER11__mbstate_tPKcS5_RS5_PDiS7_RS7_ + T _ZNKSt3__114__codecvt_utf8IDiE6do_outER11__mbstate_tPKDiS5_RS5_PcS7_RS7_ + T _ZNKSt3__114__codecvt_utf8IDiE9do_lengthER11__mbstate_tPKcS5_j + T _ZNKSt3__114__codecvt_utf8IDsE10do_unshiftER11__mbstate_tPcS4_RS4_ T _ZNKSt3__114__codecvt_utf8IDsE11do_encodingEv T _ZNKSt3__114__codecvt_utf8IDsE13do_max_lengthEv T _ZNKSt3__114__codecvt_utf8IDsE16do_always_noconvEv - T _ZNKSt3__114__codecvt_utf8IDsE5do_inER10_mbstate_tPKcS5_RS5_PDsS7_RS7_ - T _ZNKSt3__114__codecvt_utf8IDsE6do_outER10_mbstate_tPKDsS5_RS5_PcS7_RS7_ - T _ZNKSt3__114__codecvt_utf8IDsE9do_lengthER10_mbstate_tPKcS5_j - T _ZNKSt3__114__codecvt_utf8IwE10do_unshiftER10_mbstate_tPcS4_RS4_ + T _ZNKSt3__114__codecvt_utf8IDsE5do_inER11__mbstate_tPKcS5_RS5_PDsS7_RS7_ + T _ZNKSt3__114__codecvt_utf8IDsE6do_outER11__mbstate_tPKDsS5_RS5_PcS7_RS7_ + T _ZNKSt3__114__codecvt_utf8IDsE9do_lengthER11__mbstate_tPKcS5_j + T _ZNKSt3__114__codecvt_utf8IwE10do_unshiftER11__mbstate_tPcS4_RS4_ T _ZNKSt3__114__codecvt_utf8IwE11do_encodingEv T _ZNKSt3__114__codecvt_utf8IwE13do_max_lengthEv T _ZNKSt3__114__codecvt_utf8IwE16do_always_noconvEv - T _ZNKSt3__114__codecvt_utf8IwE5do_inER10_mbstate_tPKcS5_RS5_PwS7_RS7_ - T _ZNKSt3__114__codecvt_utf8IwE6do_outER10_mbstate_tPKwS5_RS5_PcS7_RS7_ - T _ZNKSt3__114__codecvt_utf8IwE9do_lengthER10_mbstate_tPKcS5_j + T _ZNKSt3__114__codecvt_utf8IwE5do_inER11__mbstate_tPKcS5_RS5_PwS7_RS7_ + T _ZNKSt3__114__codecvt_utf8IwE6do_outER11__mbstate_tPKwS5_RS5_PcS7_RS7_ + T _ZNKSt3__114__codecvt_utf8IwE9do_lengthER11__mbstate_tPKcS5_j T _ZNKSt3__114collate_bynameIcE10do_compareEPKcS3_S3_S3_ T _ZNKSt3__114collate_bynameIcE12do_transformEPKcS3_ T _ZNKSt3__114collate_bynameIwE10do_compareEPKwS3_S3_S3_ @@ -263,48 +263,48 @@ T _ZNKSt3__114error_category10equivalentERKNS_10error_codeEi T _ZNKSt3__114error_category10equivalentEiRKNS_15error_conditionE T _ZNKSt3__114error_category23default_error_conditionEi - T _ZNKSt3__115__codecvt_utf16IDiLb0EE10do_unshiftER10_mbstate_tPcS4_RS4_ + T _ZNKSt3__115__codecvt_utf16IDiLb0EE10do_unshiftER11__mbstate_tPcS4_RS4_ T _ZNKSt3__115__codecvt_utf16IDiLb0EE11do_encodingEv T _ZNKSt3__115__codecvt_utf16IDiLb0EE13do_max_lengthEv T _ZNKSt3__115__codecvt_utf16IDiLb0EE16do_always_noconvEv - T _ZNKSt3__115__codecvt_utf16IDiLb0EE5do_inER10_mbstate_tPKcS5_RS5_PDiS7_RS7_ - T _ZNKSt3__115__codecvt_utf16IDiLb0EE6do_outER10_mbstate_tPKDiS5_RS5_PcS7_RS7_ - T _ZNKSt3__115__codecvt_utf16IDiLb0EE9do_lengthER10_mbstate_tPKcS5_j - T _ZNKSt3__115__codecvt_utf16IDiLb1EE10do_unshiftER10_mbstate_tPcS4_RS4_ + T _ZNKSt3__115__codecvt_utf16IDiLb0EE5do_inER11__mbstate_tPKcS5_RS5_PDiS7_RS7_ + T _ZNKSt3__115__codecvt_utf16IDiLb0EE6do_outER11__mbstate_tPKDiS5_RS5_PcS7_RS7_ + T _ZNKSt3__115__codecvt_utf16IDiLb0EE9do_lengthER11__mbstate_tPKcS5_j + T _ZNKSt3__115__codecvt_utf16IDiLb1EE10do_unshiftER11__mbstate_tPcS4_RS4_ T _ZNKSt3__115__codecvt_utf16IDiLb1EE11do_encodingEv T _ZNKSt3__115__codecvt_utf16IDiLb1EE13do_max_lengthEv T _ZNKSt3__115__codecvt_utf16IDiLb1EE16do_always_noconvEv - T _ZNKSt3__115__codecvt_utf16IDiLb1EE5do_inER10_mbstate_tPKcS5_RS5_PDiS7_RS7_ - T _ZNKSt3__115__codecvt_utf16IDiLb1EE6do_outER10_mbstate_tPKDiS5_RS5_PcS7_RS7_ - T _ZNKSt3__115__codecvt_utf16IDiLb1EE9do_lengthER10_mbstate_tPKcS5_j - T _ZNKSt3__115__codecvt_utf16IDsLb0EE10do_unshiftER10_mbstate_tPcS4_RS4_ + T _ZNKSt3__115__codecvt_utf16IDiLb1EE5do_inER11__mbstate_tPKcS5_RS5_PDiS7_RS7_ + T _ZNKSt3__115__codecvt_utf16IDiLb1EE6do_outER11__mbstate_tPKDiS5_RS5_PcS7_RS7_ + T _ZNKSt3__115__codecvt_utf16IDiLb1EE9do_lengthER11__mbstate_tPKcS5_j + T _ZNKSt3__115__codecvt_utf16IDsLb0EE10do_unshiftER11__mbstate_tPcS4_RS4_ T _ZNKSt3__115__codecvt_utf16IDsLb0EE11do_encodingEv T _ZNKSt3__115__codecvt_utf16IDsLb0EE13do_max_lengthEv T _ZNKSt3__115__codecvt_utf16IDsLb0EE16do_always_noconvEv - T _ZNKSt3__115__codecvt_utf16IDsLb0EE5do_inER10_mbstate_tPKcS5_RS5_PDsS7_RS7_ - T _ZNKSt3__115__codecvt_utf16IDsLb0EE6do_outER10_mbstate_tPKDsS5_RS5_PcS7_RS7_ - T _ZNKSt3__115__codecvt_utf16IDsLb0EE9do_lengthER10_mbstate_tPKcS5_j - T _ZNKSt3__115__codecvt_utf16IDsLb1EE10do_unshiftER10_mbstate_tPcS4_RS4_ + T _ZNKSt3__115__codecvt_utf16IDsLb0EE5do_inER11__mbstate_tPKcS5_RS5_PDsS7_RS7_ + T _ZNKSt3__115__codecvt_utf16IDsLb0EE6do_outER11__mbstate_tPKDsS5_RS5_PcS7_RS7_ + T _ZNKSt3__115__codecvt_utf16IDsLb0EE9do_lengthER11__mbstate_tPKcS5_j + T _ZNKSt3__115__codecvt_utf16IDsLb1EE10do_unshiftER11__mbstate_tPcS4_RS4_ T _ZNKSt3__115__codecvt_utf16IDsLb1EE11do_encodingEv T _ZNKSt3__115__codecvt_utf16IDsLb1EE13do_max_lengthEv T _ZNKSt3__115__codecvt_utf16IDsLb1EE16do_always_noconvEv - T _ZNKSt3__115__codecvt_utf16IDsLb1EE5do_inER10_mbstate_tPKcS5_RS5_PDsS7_RS7_ - T _ZNKSt3__115__codecvt_utf16IDsLb1EE6do_outER10_mbstate_tPKDsS5_RS5_PcS7_RS7_ - T _ZNKSt3__115__codecvt_utf16IDsLb1EE9do_lengthER10_mbstate_tPKcS5_j - T _ZNKSt3__115__codecvt_utf16IwLb0EE10do_unshiftER10_mbstate_tPcS4_RS4_ + T _ZNKSt3__115__codecvt_utf16IDsLb1EE5do_inER11__mbstate_tPKcS5_RS5_PDsS7_RS7_ + T _ZNKSt3__115__codecvt_utf16IDsLb1EE6do_outER11__mbstate_tPKDsS5_RS5_PcS7_RS7_ + T _ZNKSt3__115__codecvt_utf16IDsLb1EE9do_lengthER11__mbstate_tPKcS5_j + T _ZNKSt3__115__codecvt_utf16IwLb0EE10do_unshiftER11__mbstate_tPcS4_RS4_ T _ZNKSt3__115__codecvt_utf16IwLb0EE11do_encodingEv T _ZNKSt3__115__codecvt_utf16IwLb0EE13do_max_lengthEv T _ZNKSt3__115__codecvt_utf16IwLb0EE16do_always_noconvEv - T _ZNKSt3__115__codecvt_utf16IwLb0EE5do_inER10_mbstate_tPKcS5_RS5_PwS7_RS7_ - T _ZNKSt3__115__codecvt_utf16IwLb0EE6do_outER10_mbstate_tPKwS5_RS5_PcS7_RS7_ - T _ZNKSt3__115__codecvt_utf16IwLb0EE9do_lengthER10_mbstate_tPKcS5_j - T _ZNKSt3__115__codecvt_utf16IwLb1EE10do_unshiftER10_mbstate_tPcS4_RS4_ + T _ZNKSt3__115__codecvt_utf16IwLb0EE5do_inER11__mbstate_tPKcS5_RS5_PwS7_RS7_ + T _ZNKSt3__115__codecvt_utf16IwLb0EE6do_outER11__mbstate_tPKwS5_RS5_PcS7_RS7_ + T _ZNKSt3__115__codecvt_utf16IwLb0EE9do_lengthER11__mbstate_tPKcS5_j + T _ZNKSt3__115__codecvt_utf16IwLb1EE10do_unshiftER11__mbstate_tPcS4_RS4_ T _ZNKSt3__115__codecvt_utf16IwLb1EE11do_encodingEv T _ZNKSt3__115__codecvt_utf16IwLb1EE13do_max_lengthEv T _ZNKSt3__115__codecvt_utf16IwLb1EE16do_always_noconvEv - T _ZNKSt3__115__codecvt_utf16IwLb1EE5do_inER10_mbstate_tPKcS5_RS5_PwS7_RS7_ - T _ZNKSt3__115__codecvt_utf16IwLb1EE6do_outER10_mbstate_tPKwS5_RS5_PcS7_RS7_ - T _ZNKSt3__115__codecvt_utf16IwLb1EE9do_lengthER10_mbstate_tPKcS5_j + T _ZNKSt3__115__codecvt_utf16IwLb1EE5do_inER11__mbstate_tPKcS5_RS5_PwS7_RS7_ + T _ZNKSt3__115__codecvt_utf16IwLb1EE6do_outER11__mbstate_tPKwS5_RS5_PcS7_RS7_ + T _ZNKSt3__115__codecvt_utf16IwLb1EE9do_lengthER11__mbstate_tPKcS5_j W _ZNKSt3__115basic_streambufIcNS_11char_traitsIcEEE4gptrEv W _ZNKSt3__115basic_streambufIcNS_11char_traitsIcEEE4pptrEv W _ZNKSt3__115basic_streambufIcNS_11char_traitsIcEEE5ebackEv @@ -377,27 +377,27 @@ T _ZNKSt3__119__iostream_category4nameEv T _ZNKSt3__119__iostream_category7messageEi T _ZNKSt3__119__shared_weak_count13__get_deleterERKSt9type_info - T _ZNKSt3__120__codecvt_utf8_utf16IDiE10do_unshiftER10_mbstate_tPcS4_RS4_ + T _ZNKSt3__120__codecvt_utf8_utf16IDiE10do_unshiftER11__mbstate_tPcS4_RS4_ T _ZNKSt3__120__codecvt_utf8_utf16IDiE11do_encodingEv T _ZNKSt3__120__codecvt_utf8_utf16IDiE13do_max_lengthEv T _ZNKSt3__120__codecvt_utf8_utf16IDiE16do_always_noconvEv - T _ZNKSt3__120__codecvt_utf8_utf16IDiE5do_inER10_mbstate_tPKcS5_RS5_PDiS7_RS7_ - T _ZNKSt3__120__codecvt_utf8_utf16IDiE6do_outER10_mbstate_tPKDiS5_RS5_PcS7_RS7_ - T _ZNKSt3__120__codecvt_utf8_utf16IDiE9do_lengthER10_mbstate_tPKcS5_j - T _ZNKSt3__120__codecvt_utf8_utf16IDsE10do_unshiftER10_mbstate_tPcS4_RS4_ + T _ZNKSt3__120__codecvt_utf8_utf16IDiE5do_inER11__mbstate_tPKcS5_RS5_PDiS7_RS7_ + T _ZNKSt3__120__codecvt_utf8_utf16IDiE6do_outER11__mbstate_tPKDiS5_RS5_PcS7_RS7_ + T _ZNKSt3__120__codecvt_utf8_utf16IDiE9do_lengthER11__mbstate_tPKcS5_j + T _ZNKSt3__120__codecvt_utf8_utf16IDsE10do_unshiftER11__mbstate_tPcS4_RS4_ T _ZNKSt3__120__codecvt_utf8_utf16IDsE11do_encodingEv T _ZNKSt3__120__codecvt_utf8_utf16IDsE13do_max_lengthEv T _ZNKSt3__120__codecvt_utf8_utf16IDsE16do_always_noconvEv - T _ZNKSt3__120__codecvt_utf8_utf16IDsE5do_inER10_mbstate_tPKcS5_RS5_PDsS7_RS7_ - T _ZNKSt3__120__codecvt_utf8_utf16IDsE6do_outER10_mbstate_tPKDsS5_RS5_PcS7_RS7_ - T _ZNKSt3__120__codecvt_utf8_utf16IDsE9do_lengthER10_mbstate_tPKcS5_j - T _ZNKSt3__120__codecvt_utf8_utf16IwE10do_unshiftER10_mbstate_tPcS4_RS4_ + T _ZNKSt3__120__codecvt_utf8_utf16IDsE5do_inER11__mbstate_tPKcS5_RS5_PDsS7_RS7_ + T _ZNKSt3__120__codecvt_utf8_utf16IDsE6do_outER11__mbstate_tPKDsS5_RS5_PcS7_RS7_ + T _ZNKSt3__120__codecvt_utf8_utf16IDsE9do_lengthER11__mbstate_tPKcS5_j + T _ZNKSt3__120__codecvt_utf8_utf16IwE10do_unshiftER11__mbstate_tPcS4_RS4_ T _ZNKSt3__120__codecvt_utf8_utf16IwE11do_encodingEv T _ZNKSt3__120__codecvt_utf8_utf16IwE13do_max_lengthEv T _ZNKSt3__120__codecvt_utf8_utf16IwE16do_always_noconvEv - T _ZNKSt3__120__codecvt_utf8_utf16IwE5do_inER10_mbstate_tPKcS5_RS5_PwS7_RS7_ - T _ZNKSt3__120__codecvt_utf8_utf16IwE6do_outER10_mbstate_tPKwS5_RS5_PcS7_RS7_ - T _ZNKSt3__120__codecvt_utf8_utf16IwE9do_lengthER10_mbstate_tPKcS5_j + T _ZNKSt3__120__codecvt_utf8_utf16IwE5do_inER11__mbstate_tPKcS5_RS5_PwS7_RS7_ + T _ZNKSt3__120__codecvt_utf8_utf16IwE6do_outER11__mbstate_tPKwS5_RS5_PcS7_RS7_ + T _ZNKSt3__120__codecvt_utf8_utf16IwE9do_lengthER11__mbstate_tPKcS5_j T _ZNKSt3__120__time_get_c_storageIcE3__XEv T _ZNKSt3__120__time_get_c_storageIcE3__cEv T _ZNKSt3__120__time_get_c_storageIcE3__rEv @@ -450,34 +450,34 @@ T _ZNKSt3__16locale9has_facetERNS0_2idE T _ZNKSt3__16locale9use_facetERNS0_2idE T _ZNKSt3__16localeeqERKS0_ - T _ZNKSt3__17codecvtIDic10_mbstate_tE10do_unshiftERS1_PcS4_RS4_ - T _ZNKSt3__17codecvtIDic10_mbstate_tE11do_encodingEv - T _ZNKSt3__17codecvtIDic10_mbstate_tE13do_max_lengthEv - T _ZNKSt3__17codecvtIDic10_mbstate_tE16do_always_noconvEv - T _ZNKSt3__17codecvtIDic10_mbstate_tE5do_inERS1_PKcS5_RS5_PDiS7_RS7_ - T _ZNKSt3__17codecvtIDic10_mbstate_tE6do_outERS1_PKDiS5_RS5_PcS7_RS7_ - T _ZNKSt3__17codecvtIDic10_mbstate_tE9do_lengthERS1_PKcS5_j - T _ZNKSt3__17codecvtIDsc10_mbstate_tE10do_unshiftERS1_PcS4_RS4_ - T _ZNKSt3__17codecvtIDsc10_mbstate_tE11do_encodingEv - T _ZNKSt3__17codecvtIDsc10_mbstate_tE13do_max_lengthEv - T _ZNKSt3__17codecvtIDsc10_mbstate_tE16do_always_noconvEv - T _ZNKSt3__17codecvtIDsc10_mbstate_tE5do_inERS1_PKcS5_RS5_PDsS7_RS7_ - T _ZNKSt3__17codecvtIDsc10_mbstate_tE6do_outERS1_PKDsS5_RS5_PcS7_RS7_ - T _ZNKSt3__17codecvtIDsc10_mbstate_tE9do_lengthERS1_PKcS5_j - T _ZNKSt3__17codecvtIcc10_mbstate_tE10do_unshiftERS1_PcS4_RS4_ - T _ZNKSt3__17codecvtIcc10_mbstate_tE11do_encodingEv - T _ZNKSt3__17codecvtIcc10_mbstate_tE13do_max_lengthEv - T _ZNKSt3__17codecvtIcc10_mbstate_tE16do_always_noconvEv - T _ZNKSt3__17codecvtIcc10_mbstate_tE5do_inERS1_PKcS5_RS5_PcS7_RS7_ - T _ZNKSt3__17codecvtIcc10_mbstate_tE6do_outERS1_PKcS5_RS5_PcS7_RS7_ - T _ZNKSt3__17codecvtIcc10_mbstate_tE9do_lengthERS1_PKcS5_j - T _ZNKSt3__17codecvtIwc10_mbstate_tE10do_unshiftERS1_PcS4_RS4_ - T _ZNKSt3__17codecvtIwc10_mbstate_tE11do_encodingEv - T _ZNKSt3__17codecvtIwc10_mbstate_tE13do_max_lengthEv - T _ZNKSt3__17codecvtIwc10_mbstate_tE16do_always_noconvEv - T _ZNKSt3__17codecvtIwc10_mbstate_tE5do_inERS1_PKcS5_RS5_PwS7_RS7_ - T _ZNKSt3__17codecvtIwc10_mbstate_tE6do_outERS1_PKwS5_RS5_PcS7_RS7_ - T _ZNKSt3__17codecvtIwc10_mbstate_tE9do_lengthERS1_PKcS5_j + T _ZNKSt3__17codecvtIDic11__mbstate_tE10do_unshiftERS1_PcS4_RS4_ + T _ZNKSt3__17codecvtIDic11__mbstate_tE11do_encodingEv + T _ZNKSt3__17codecvtIDic11__mbstate_tE13do_max_lengthEv + T _ZNKSt3__17codecvtIDic11__mbstate_tE16do_always_noconvEv + T _ZNKSt3__17codecvtIDic11__mbstate_tE5do_inERS1_PKcS5_RS5_PDiS7_RS7_ + T _ZNKSt3__17codecvtIDic11__mbstate_tE6do_outERS1_PKDiS5_RS5_PcS7_RS7_ + T _ZNKSt3__17codecvtIDic11__mbstate_tE9do_lengthERS1_PKcS5_j + T _ZNKSt3__17codecvtIDsc11__mbstate_tE10do_unshiftERS1_PcS4_RS4_ + T _ZNKSt3__17codecvtIDsc11__mbstate_tE11do_encodingEv + T _ZNKSt3__17codecvtIDsc11__mbstate_tE13do_max_lengthEv + T _ZNKSt3__17codecvtIDsc11__mbstate_tE16do_always_noconvEv + T _ZNKSt3__17codecvtIDsc11__mbstate_tE5do_inERS1_PKcS5_RS5_PDsS7_RS7_ + T _ZNKSt3__17codecvtIDsc11__mbstate_tE6do_outERS1_PKDsS5_RS5_PcS7_RS7_ + T _ZNKSt3__17codecvtIDsc11__mbstate_tE9do_lengthERS1_PKcS5_j + T _ZNKSt3__17codecvtIcc11__mbstate_tE10do_unshiftERS1_PcS4_RS4_ + T _ZNKSt3__17codecvtIcc11__mbstate_tE11do_encodingEv + T _ZNKSt3__17codecvtIcc11__mbstate_tE13do_max_lengthEv + T _ZNKSt3__17codecvtIcc11__mbstate_tE16do_always_noconvEv + T _ZNKSt3__17codecvtIcc11__mbstate_tE5do_inERS1_PKcS5_RS5_PcS7_RS7_ + T _ZNKSt3__17codecvtIcc11__mbstate_tE6do_outERS1_PKcS5_RS5_PcS7_RS7_ + T _ZNKSt3__17codecvtIcc11__mbstate_tE9do_lengthERS1_PKcS5_j + T _ZNKSt3__17codecvtIwc11__mbstate_tE10do_unshiftERS1_PcS4_RS4_ + T _ZNKSt3__17codecvtIwc11__mbstate_tE11do_encodingEv + T _ZNKSt3__17codecvtIwc11__mbstate_tE13do_max_lengthEv + T _ZNKSt3__17codecvtIwc11__mbstate_tE16do_always_noconvEv + T _ZNKSt3__17codecvtIwc11__mbstate_tE5do_inERS1_PKcS5_RS5_PwS7_RS7_ + T _ZNKSt3__17codecvtIwc11__mbstate_tE6do_outERS1_PKwS5_RS5_PcS7_RS7_ + T _ZNKSt3__17codecvtIwc11__mbstate_tE9do_lengthERS1_PKcS5_j W _ZNKSt3__17collateIcE10do_compareEPKcS3_S3_S3_ W _ZNKSt3__17collateIcE12do_transformEPKcS3_ W _ZNKSt3__17collateIcE4hashEPKcS3_ @@ -490,6 +490,15 @@ W _ZNKSt3__17collateIwE7compareEPKwS3_S3_S3_ W _ZNKSt3__17collateIwE7do_hashEPKwS3_ W _ZNKSt3__17collateIwE9transformEPKwS3_ + C _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE15__do_get_signedIlEES4_S4_S4_RNS_8ios_baseERjRT_ + C _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE15__do_get_signedIxEES4_S4_S4_RNS_8ios_baseERjRT_ + C _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE17__do_get_unsignedIjEES4_S4_S4_RNS_8ios_baseERjRT_ + C _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE17__do_get_unsignedImEES4_S4_S4_RNS_8ios_baseERjRT_ + C _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE17__do_get_unsignedItEES4_S4_S4_RNS_8ios_baseERjRT_ + C _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE17__do_get_unsignedIyEES4_S4_S4_RNS_8ios_baseERjRT_ + C _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE23__do_get_floating_pointIdEES4_S4_S4_RNS_8ios_baseERjRT_ + C _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE23__do_get_floating_pointIeEES4_S4_S4_RNS_8ios_baseERjRT_ + C _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE23__do_get_floating_pointIfEES4_S4_S4_RNS_8ios_baseERjRT_ W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjRPv W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjRb W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE3getES4_S4_RNS_8ios_baseERjRd @@ -512,6 +521,15 @@ W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjRx W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjRy W _ZNKSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEE6do_getES4_S4_RNS_8ios_baseERjS8_ + C _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE15__do_get_signedIlEES4_S4_S4_RNS_8ios_baseERjRT_ + C _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE15__do_get_signedIxEES4_S4_S4_RNS_8ios_baseERjRT_ + C _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE17__do_get_unsignedIjEES4_S4_S4_RNS_8ios_baseERjRT_ + C _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE17__do_get_unsignedImEES4_S4_S4_RNS_8ios_baseERjRT_ + C _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE17__do_get_unsignedItEES4_S4_S4_RNS_8ios_baseERjRT_ + C _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE17__do_get_unsignedIyEES4_S4_S4_RNS_8ios_baseERjRT_ + C _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE23__do_get_floating_pointIdEES4_S4_S4_RNS_8ios_baseERjRT_ + C _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE23__do_get_floating_pointIeEES4_S4_S4_RNS_8ios_baseERjRT_ + C _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE23__do_get_floating_pointIfEES4_S4_S4_RNS_8ios_baseERjRT_ W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjRPv W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjRb W _ZNKSt3__17num_getIwNS_19istreambuf_iteratorIwNS_11char_traitsIwEEEEE3getES4_S4_RNS_8ios_baseERjRd @@ -751,21 +769,21 @@ T _ZNSt16nested_exceptionD0Ev T _ZNSt16nested_exceptionD1Ev T _ZNSt16nested_exceptionD2Ev - C _ZNSt3__110__sscanf_lEPKcPvS1_z + C _ZNSt3__110__sscanf_lEPKcP15__locale_structS1_z C _ZNSt3__110__stdinbufIcE5imbueERKNS_6localeE C _ZNSt3__110__stdinbufIcE5uflowEv C _ZNSt3__110__stdinbufIcE9__getcharEb C _ZNSt3__110__stdinbufIcE9pbackfailEi C _ZNSt3__110__stdinbufIcE9underflowEv - C _ZNSt3__110__stdinbufIcEC2EP7__sFILEP10_mbstate_t + C _ZNSt3__110__stdinbufIcEC2EP8_IO_FILEP11__mbstate_t C _ZNSt3__110__stdinbufIcED0Ev C _ZNSt3__110__stdinbufIcED1Ev C _ZNSt3__110__stdinbufIwE5imbueERKNS_6localeE C _ZNSt3__110__stdinbufIwE5uflowEv C _ZNSt3__110__stdinbufIwE9__getcharEb - C _ZNSt3__110__stdinbufIwE9pbackfailEi + C _ZNSt3__110__stdinbufIwE9pbackfailEj C _ZNSt3__110__stdinbufIwE9underflowEv - C _ZNSt3__110__stdinbufIwEC2EP7__sFILEP10_mbstate_t + C _ZNSt3__110__stdinbufIwEC2EP8_IO_FILEP11__mbstate_t C _ZNSt3__110__stdinbufIwED0Ev C _ZNSt3__110__stdinbufIwED1Ev T _ZNSt3__110__time_getC1EPKc @@ -867,12 +885,14 @@ W _ZNSt3__111__money_putIwEC2Ev C _ZNSt3__111__stdoutbufIcE4syncEv C _ZNSt3__111__stdoutbufIcE5imbueERKNS_6localeE + C _ZNSt3__111__stdoutbufIcE6xsputnEPKci C _ZNSt3__111__stdoutbufIcE8overflowEi C _ZNSt3__111__stdoutbufIcED0Ev C _ZNSt3__111__stdoutbufIcED1Ev C _ZNSt3__111__stdoutbufIwE4syncEv C _ZNSt3__111__stdoutbufIwE5imbueERKNS_6localeE - C _ZNSt3__111__stdoutbufIwE8overflowEi + C _ZNSt3__111__stdoutbufIwE6xsputnEPKwi + C _ZNSt3__111__stdoutbufIwE8overflowEj C _ZNSt3__111__stdoutbufIwED0Ev C _ZNSt3__111__stdoutbufIwED1Ev T _ZNSt3__111regex_errorC1ENS_15regex_constants10error_typeE @@ -889,7 +909,7 @@ T _ZNSt3__111timed_mutexD1Ev T _ZNSt3__111timed_mutexD2Ev D _ZNSt3__111try_to_lockE - C _ZNSt3__112__asprintf_lEPPcPvPKcz + C _ZNSt3__112__asprintf_lEPPcP15__locale_structPKcz C _ZNSt3__112__do_messageD0Ev C _ZNSt3__112__do_messageD1Ev T _ZNSt3__112__do_nothingEPv @@ -903,7 +923,7 @@ T _ZNSt3__112__rs_defaultD1Ev T _ZNSt3__112__rs_defaultD2Ev T _ZNSt3__112__rs_defaultclEv - C _ZNSt3__112__snprintf_lEPcjPvPKcz + C _ZNSt3__112__snprintf_lEPcjP15__locale_structPKcz T _ZNSt3__112bad_weak_ptrD0Ev T _ZNSt3__112bad_weak_ptrD1Ev T _ZNSt3__112bad_weak_ptrD2Ev @@ -1190,7 +1210,7 @@ T _ZNSt3__112strstreambuf6__initEPciS1_ T _ZNSt3__112strstreambuf6freezeEb T _ZNSt3__112strstreambuf7seekoffExNS_8ios_base7seekdirEj - T _ZNSt3__112strstreambuf7seekposENS_4fposI10_mbstate_tEEj + T _ZNSt3__112strstreambuf7seekposENS_4fposI11__mbstate_tEEj T _ZNSt3__112strstreambuf8overflowEi T _ZNSt3__112strstreambuf9pbackfailEi T _ZNSt3__112strstreambuf9underflowEv @@ -1240,7 +1260,7 @@ W _ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE4readEPci W _ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE4swapERS3_ W _ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE4syncEv - W _ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE5seekgENS_4fposI10_mbstate_tEE + W _ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE5seekgENS_4fposI11__mbstate_tEE W _ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE5seekgExNS_8ios_base7seekdirE W _ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE5tellgEv W _ZNSt3__113basic_istreamIcNS_11char_traitsIcEEE5ungetEv @@ -1286,11 +1306,11 @@ W _ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE4readEPwi W _ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE4swapERS3_ W _ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE4syncEv - W _ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE5seekgENS_4fposI10_mbstate_tEE + W _ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE5seekgENS_4fposI11__mbstate_tEE W _ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE5seekgExNS_8ios_base7seekdirE W _ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE5tellgEv W _ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE5ungetEv - W _ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE6ignoreEii + W _ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE6ignoreEij W _ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE6sentryC1ERS3_b W _ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE6sentryC2ERS3_b W _ZNSt3__113basic_istreamIwNS_11char_traitsIwEEE7getlineEPwi @@ -1325,7 +1345,7 @@ W _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE3putEc W _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE4swapERS3_ W _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5flushEv - W _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5seekpENS_4fposI10_mbstate_tEE + W _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5seekpENS_4fposI11__mbstate_tEE W _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5seekpExNS_8ios_base7seekdirE W _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5tellpEv W _ZNSt3__113basic_ostreamIcNS_11char_traitsIcEEE5writeEPKci @@ -1363,7 +1383,7 @@ W _ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE3putEw W _ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE4swapERS3_ W _ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5flushEv - W _ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5seekpENS_4fposI10_mbstate_tEE + W _ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5seekpENS_4fposI11__mbstate_tEE W _ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5seekpExNS_8ios_base7seekdirE W _ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5tellpEv W _ZNSt3__113basic_ostreamIwNS_11char_traitsIwEEE5writeEPKwi @@ -1436,34 +1456,34 @@ W _ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEED1Ev W _ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEED2Ev W _ZNSt3__114basic_iostreamIcNS_11char_traitsIcEEEaSEOS3_ - W _ZNSt3__114codecvt_bynameIDic10_mbstate_tEC1EPKcj - W _ZNSt3__114codecvt_bynameIDic10_mbstate_tEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj - W _ZNSt3__114codecvt_bynameIDic10_mbstate_tEC2EPKcj - W _ZNSt3__114codecvt_bynameIDic10_mbstate_tEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj - W _ZNSt3__114codecvt_bynameIDic10_mbstate_tED0Ev - W _ZNSt3__114codecvt_bynameIDic10_mbstate_tED1Ev - W _ZNSt3__114codecvt_bynameIDic10_mbstate_tED2Ev - W _ZNSt3__114codecvt_bynameIDsc10_mbstate_tEC1EPKcj - W _ZNSt3__114codecvt_bynameIDsc10_mbstate_tEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj - W _ZNSt3__114codecvt_bynameIDsc10_mbstate_tEC2EPKcj - W _ZNSt3__114codecvt_bynameIDsc10_mbstate_tEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj - W _ZNSt3__114codecvt_bynameIDsc10_mbstate_tED0Ev - W _ZNSt3__114codecvt_bynameIDsc10_mbstate_tED1Ev - W _ZNSt3__114codecvt_bynameIDsc10_mbstate_tED2Ev - W _ZNSt3__114codecvt_bynameIcc10_mbstate_tEC1EPKcj - W _ZNSt3__114codecvt_bynameIcc10_mbstate_tEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj - W _ZNSt3__114codecvt_bynameIcc10_mbstate_tEC2EPKcj - W _ZNSt3__114codecvt_bynameIcc10_mbstate_tEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj - W _ZNSt3__114codecvt_bynameIcc10_mbstate_tED0Ev - W _ZNSt3__114codecvt_bynameIcc10_mbstate_tED1Ev - W _ZNSt3__114codecvt_bynameIcc10_mbstate_tED2Ev - W _ZNSt3__114codecvt_bynameIwc10_mbstate_tEC1EPKcj - W _ZNSt3__114codecvt_bynameIwc10_mbstate_tEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj - W _ZNSt3__114codecvt_bynameIwc10_mbstate_tEC2EPKcj - W _ZNSt3__114codecvt_bynameIwc10_mbstate_tEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj - W _ZNSt3__114codecvt_bynameIwc10_mbstate_tED0Ev - W _ZNSt3__114codecvt_bynameIwc10_mbstate_tED1Ev - W _ZNSt3__114codecvt_bynameIwc10_mbstate_tED2Ev + W _ZNSt3__114codecvt_bynameIDic11__mbstate_tEC1EPKcj + W _ZNSt3__114codecvt_bynameIDic11__mbstate_tEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj + W _ZNSt3__114codecvt_bynameIDic11__mbstate_tEC2EPKcj + W _ZNSt3__114codecvt_bynameIDic11__mbstate_tEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj + W _ZNSt3__114codecvt_bynameIDic11__mbstate_tED0Ev + W _ZNSt3__114codecvt_bynameIDic11__mbstate_tED1Ev + W _ZNSt3__114codecvt_bynameIDic11__mbstate_tED2Ev + W _ZNSt3__114codecvt_bynameIDsc11__mbstate_tEC1EPKcj + W _ZNSt3__114codecvt_bynameIDsc11__mbstate_tEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj + W _ZNSt3__114codecvt_bynameIDsc11__mbstate_tEC2EPKcj + W _ZNSt3__114codecvt_bynameIDsc11__mbstate_tEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj + W _ZNSt3__114codecvt_bynameIDsc11__mbstate_tED0Ev + W _ZNSt3__114codecvt_bynameIDsc11__mbstate_tED1Ev + W _ZNSt3__114codecvt_bynameIDsc11__mbstate_tED2Ev + W _ZNSt3__114codecvt_bynameIcc11__mbstate_tEC1EPKcj + W _ZNSt3__114codecvt_bynameIcc11__mbstate_tEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj + W _ZNSt3__114codecvt_bynameIcc11__mbstate_tEC2EPKcj + W _ZNSt3__114codecvt_bynameIcc11__mbstate_tEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj + W _ZNSt3__114codecvt_bynameIcc11__mbstate_tED0Ev + W _ZNSt3__114codecvt_bynameIcc11__mbstate_tED1Ev + W _ZNSt3__114codecvt_bynameIcc11__mbstate_tED2Ev + W _ZNSt3__114codecvt_bynameIwc11__mbstate_tEC1EPKcj + W _ZNSt3__114codecvt_bynameIwc11__mbstate_tEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj + W _ZNSt3__114codecvt_bynameIwc11__mbstate_tEC2EPKcj + W _ZNSt3__114codecvt_bynameIwc11__mbstate_tEC2ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj + W _ZNSt3__114codecvt_bynameIwc11__mbstate_tED0Ev + W _ZNSt3__114codecvt_bynameIwc11__mbstate_tED1Ev + W _ZNSt3__114codecvt_bynameIwc11__mbstate_tED2Ev T _ZNSt3__114collate_bynameIcEC1EPKcj T _ZNSt3__114collate_bynameIcEC1ERKNS_12basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEEj T _ZNSt3__114collate_bynameIcEC2EPKcj @@ -1509,7 +1529,7 @@ C _ZNSt3__115__time_get_tempIwED0Ev C _ZNSt3__115__time_get_tempIwED1Ev W _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE10pubseekoffExNS_8ios_base7seekdirEj - W _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE10pubseekposENS_4fposI10_mbstate_tEEj + W _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE10pubseekposENS_4fposI11__mbstate_tEEj W _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE4setgEPcS4_S4_ W _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE4setpEPcS4_ W _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE4swapERS3_ @@ -1529,7 +1549,7 @@ W _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE6xsputnEPKci W _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE7pubsyncEv W _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE7seekoffExNS_8ios_base7seekdirEj - W _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE7seekposENS_4fposI10_mbstate_tEEj + W _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE7seekposENS_4fposI11__mbstate_tEEj W _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE7sungetcEv W _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE8in_availEv W _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEE8overflowEi @@ -1548,7 +1568,7 @@ W _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEED2Ev W _ZNSt3__115basic_streambufIcNS_11char_traitsIcEEEaSERKS3_ W _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE10pubseekoffExNS_8ios_base7seekdirEj - W _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE10pubseekposENS_4fposI10_mbstate_tEEj + W _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE10pubseekposENS_4fposI11__mbstate_tEEj W _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE4setgEPwS4_S4_ W _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE4setpEPwS4_ W _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE4swapERS3_ @@ -1568,12 +1588,12 @@ W _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE6xsputnEPKwi W _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE7pubsyncEv W _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE7seekoffExNS_8ios_base7seekdirEj - W _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE7seekposENS_4fposI10_mbstate_tEEj + W _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE7seekposENS_4fposI11__mbstate_tEEj W _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE7sungetcEv W _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE8in_availEv - W _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE8overflowEi + W _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE8overflowEj W _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE8pubimbueERKNS_6localeE - W _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE9pbackfailEi + W _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE9pbackfailEj W _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE9pubsetbufEPwi W _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE9showmanycEv W _ZNSt3__115basic_streambufIwNS_11char_traitsIwEEE9sputbackcEw @@ -1956,26 +1976,26 @@ C _ZNSt3__17__sort5IRNS_6__lessIwwEEPwEEjT0_S5_S5_S5_S5_T_ C _ZNSt3__17__sort5IRNS_6__lessIxxEEPxEEjT0_S5_S5_S5_S5_T_ C _ZNSt3__17__sort5IRNS_6__lessIyyEEPyEEjT0_S5_S5_S5_S5_T_ - D _ZNSt3__17codecvtIDic10_mbstate_tE2idE - T _ZNSt3__17codecvtIDic10_mbstate_tED0Ev - T _ZNSt3__17codecvtIDic10_mbstate_tED1Ev - T _ZNSt3__17codecvtIDic10_mbstate_tED2Ev - D _ZNSt3__17codecvtIDsc10_mbstate_tE2idE - T _ZNSt3__17codecvtIDsc10_mbstate_tED0Ev - T _ZNSt3__17codecvtIDsc10_mbstate_tED1Ev - T _ZNSt3__17codecvtIDsc10_mbstate_tED2Ev - D _ZNSt3__17codecvtIcc10_mbstate_tE2idE - T _ZNSt3__17codecvtIcc10_mbstate_tED0Ev - T _ZNSt3__17codecvtIcc10_mbstate_tED1Ev - T _ZNSt3__17codecvtIcc10_mbstate_tED2Ev - D _ZNSt3__17codecvtIwc10_mbstate_tE2idE - T _ZNSt3__17codecvtIwc10_mbstate_tEC1EPKcj - T _ZNSt3__17codecvtIwc10_mbstate_tEC1Ej - T _ZNSt3__17codecvtIwc10_mbstate_tEC2EPKcj - T _ZNSt3__17codecvtIwc10_mbstate_tEC2Ej - T _ZNSt3__17codecvtIwc10_mbstate_tED0Ev - T _ZNSt3__17codecvtIwc10_mbstate_tED1Ev - T _ZNSt3__17codecvtIwc10_mbstate_tED2Ev + D _ZNSt3__17codecvtIDic11__mbstate_tE2idE + T _ZNSt3__17codecvtIDic11__mbstate_tED0Ev + T _ZNSt3__17codecvtIDic11__mbstate_tED1Ev + T _ZNSt3__17codecvtIDic11__mbstate_tED2Ev + D _ZNSt3__17codecvtIDsc11__mbstate_tE2idE + T _ZNSt3__17codecvtIDsc11__mbstate_tED0Ev + T _ZNSt3__17codecvtIDsc11__mbstate_tED1Ev + T _ZNSt3__17codecvtIDsc11__mbstate_tED2Ev + D _ZNSt3__17codecvtIcc11__mbstate_tE2idE + T _ZNSt3__17codecvtIcc11__mbstate_tED0Ev + T _ZNSt3__17codecvtIcc11__mbstate_tED1Ev + T _ZNSt3__17codecvtIcc11__mbstate_tED2Ev + D _ZNSt3__17codecvtIwc11__mbstate_tE2idE + T _ZNSt3__17codecvtIwc11__mbstate_tEC1EPKcj + T _ZNSt3__17codecvtIwc11__mbstate_tEC1Ej + T _ZNSt3__17codecvtIwc11__mbstate_tEC2EPKcj + T _ZNSt3__17codecvtIwc11__mbstate_tEC2Ej + T _ZNSt3__17codecvtIwc11__mbstate_tED0Ev + T _ZNSt3__17codecvtIwc11__mbstate_tED1Ev + T _ZNSt3__17codecvtIwc11__mbstate_tED2Ev W _ZNSt3__17collateIcE2idE W _ZNSt3__17collateIcEC1Ej W _ZNSt3__17collateIcEC2Ej @@ -2241,7 +2261,6 @@ T _ZNSt3__19to_stringEx T _ZNSt3__19to_stringEy W _ZNSt3__1plIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_12basic_stringIT_T0_T1_EEPKS6_RKS9_ - C _ZNSt3__1plIcNS_11char_traitsIcEENS_9allocatorIcEEEENS_12basic_stringIT_T0_T1_EERKS9_PKS6_ T _ZSt10unexpectedv T _ZSt13get_terminatev T _ZSt13set_terminatePFvvE @@ -2295,10 +2314,10 @@ C _ZTINSt3__114__num_put_baseE D _ZTINSt3__114__shared_countE W _ZTINSt3__114basic_iostreamIcNS_11char_traitsIcEEEE - W _ZTINSt3__114codecvt_bynameIDic10_mbstate_tEE - W _ZTINSt3__114codecvt_bynameIDsc10_mbstate_tEE - W _ZTINSt3__114codecvt_bynameIcc10_mbstate_tEE - W _ZTINSt3__114codecvt_bynameIwc10_mbstate_tEE + W _ZTINSt3__114codecvt_bynameIDic11__mbstate_tEE + W _ZTINSt3__114codecvt_bynameIDsc11__mbstate_tEE + W _ZTINSt3__114codecvt_bynameIcc11__mbstate_tEE + W _ZTINSt3__114codecvt_bynameIwc11__mbstate_tEE D _ZTINSt3__114collate_bynameIcEE D _ZTINSt3__114collate_bynameIwEE D _ZTINSt3__114error_categoryE @@ -2345,10 +2364,10 @@ D _ZTINSt3__15ctypeIwEE D _ZTINSt3__16locale5__impE D _ZTINSt3__16locale5facetE - D _ZTINSt3__17codecvtIDic10_mbstate_tEE - D _ZTINSt3__17codecvtIDsc10_mbstate_tEE - D _ZTINSt3__17codecvtIcc10_mbstate_tEE - D _ZTINSt3__17codecvtIwc10_mbstate_tEE + D _ZTINSt3__17codecvtIDic11__mbstate_tEE + D _ZTINSt3__17codecvtIDsc11__mbstate_tEE + D _ZTINSt3__17codecvtIcc11__mbstate_tEE + D _ZTINSt3__17codecvtIwc11__mbstate_tEE W _ZTINSt3__17collateIcEE W _ZTINSt3__17collateIwEE W _ZTINSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE @@ -2429,10 +2448,10 @@ C _ZTSNSt3__114__num_put_baseE D _ZTSNSt3__114__shared_countE W _ZTSNSt3__114basic_iostreamIcNS_11char_traitsIcEEEE - W _ZTSNSt3__114codecvt_bynameIDic10_mbstate_tEE - W _ZTSNSt3__114codecvt_bynameIDsc10_mbstate_tEE - W _ZTSNSt3__114codecvt_bynameIcc10_mbstate_tEE - W _ZTSNSt3__114codecvt_bynameIwc10_mbstate_tEE + W _ZTSNSt3__114codecvt_bynameIDic11__mbstate_tEE + W _ZTSNSt3__114codecvt_bynameIDsc11__mbstate_tEE + W _ZTSNSt3__114codecvt_bynameIcc11__mbstate_tEE + W _ZTSNSt3__114codecvt_bynameIwc11__mbstate_tEE D _ZTSNSt3__114collate_bynameIcEE D _ZTSNSt3__114collate_bynameIwEE D _ZTSNSt3__114error_categoryE @@ -2479,10 +2498,10 @@ D _ZTSNSt3__15ctypeIwEE D _ZTSNSt3__16locale5__impE D _ZTSNSt3__16locale5facetE - D _ZTSNSt3__17codecvtIDic10_mbstate_tEE - D _ZTSNSt3__17codecvtIDsc10_mbstate_tEE - D _ZTSNSt3__17codecvtIcc10_mbstate_tEE - D _ZTSNSt3__17codecvtIwc10_mbstate_tEE + D _ZTSNSt3__17codecvtIDic11__mbstate_tEE + D _ZTSNSt3__17codecvtIDsc11__mbstate_tEE + D _ZTSNSt3__17codecvtIcc11__mbstate_tEE + D _ZTSNSt3__17codecvtIwc11__mbstate_tEE W _ZTSNSt3__17collateIcEE W _ZTSNSt3__17collateIwEE W _ZTSNSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE @@ -2559,10 +2578,10 @@ D _ZTVNSt3__114__codecvt_utf8IwEE D _ZTVNSt3__114__shared_countE W _ZTVNSt3__114basic_iostreamIcNS_11char_traitsIcEEEE - W _ZTVNSt3__114codecvt_bynameIDic10_mbstate_tEE - W _ZTVNSt3__114codecvt_bynameIDsc10_mbstate_tEE - W _ZTVNSt3__114codecvt_bynameIcc10_mbstate_tEE - W _ZTVNSt3__114codecvt_bynameIwc10_mbstate_tEE + W _ZTVNSt3__114codecvt_bynameIDic11__mbstate_tEE + W _ZTVNSt3__114codecvt_bynameIDsc11__mbstate_tEE + W _ZTVNSt3__114codecvt_bynameIcc11__mbstate_tEE + W _ZTVNSt3__114codecvt_bynameIwc11__mbstate_tEE D _ZTVNSt3__114collate_bynameIcEE D _ZTVNSt3__114collate_bynameIwEE D _ZTVNSt3__114error_categoryE @@ -2605,10 +2624,10 @@ D _ZTVNSt3__15ctypeIwEE D _ZTVNSt3__16locale5__impE D _ZTVNSt3__16locale5facetE - D _ZTVNSt3__17codecvtIDic10_mbstate_tEE - D _ZTVNSt3__17codecvtIDsc10_mbstate_tEE - D _ZTVNSt3__17codecvtIcc10_mbstate_tEE - D _ZTVNSt3__17codecvtIwc10_mbstate_tEE + D _ZTVNSt3__17codecvtIDic11__mbstate_tEE + D _ZTVNSt3__17codecvtIDsc11__mbstate_tEE + D _ZTVNSt3__17codecvtIcc11__mbstate_tEE + D _ZTVNSt3__17codecvtIwc11__mbstate_tEE W _ZTVNSt3__17collateIcEE W _ZTVNSt3__17collateIwEE W _ZTVNSt3__17num_getIcNS_19istreambuf_iteratorIcNS_11char_traitsIcEEEEEE diff --git a/system/lib/libcxx/system_error.cpp b/system/lib/libcxx/system_error.cpp index 7376b770..b40409f8 100644 --- a/system/lib/libcxx/system_error.cpp +++ b/system/lib/libcxx/system_error.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_BUILDING_SYSTEM_ERROR #include "system_error" #include "string" #include "cstring" diff --git a/system/lib/libcxx/thread.cpp b/system/lib/libcxx/thread.cpp index 1fd8bb04..338a8a24 100644 --- a/system/lib/libcxx/thread.cpp +++ b/system/lib/libcxx/thread.cpp @@ -14,9 +14,9 @@ #include "limits" #include <sys/types.h> #if !defined(_WIN32) -#if !defined(__sun__) && !defined(__linux__) +#if !defined(__sun__) && !defined(__linux__) && !defined(_AIX) #include <sys/sysctl.h> -#endif // !__sun__ && !__linux__ +#endif // !__sun__ && !__linux__ && !_AIX #include <unistd.h> #endif // !_WIN32 @@ -89,7 +89,11 @@ thread::hardware_concurrency() _NOEXCEPT #else // defined(CTL_HW) && defined(HW_NCPU) // TODO: grovel through /proc or check cpuid on x86 and similar // instructions on other architectures. -#warning hardware_concurrency not yet implemented +# if defined(_MSC_VER) && ! defined(__clang__) + _LIBCPP_WARNING("hardware_concurrency not yet implemented") +# else +# warning hardware_concurrency not yet implemented +# endif return 0; // Means not computable [thread.thread.static] #endif // defined(CTL_HW) && defined(HW_NCPU) } diff --git a/system/lib/libcxx/typeinfo.cpp b/system/lib/libcxx/typeinfo.cpp index 60828944..b4281209 100644 --- a/system/lib/libcxx/typeinfo.cpp +++ b/system/lib/libcxx/typeinfo.cpp @@ -20,12 +20,18 @@ #include "typeinfo" -#if !(defined(_LIBCPPABI_VERSION) || defined(LIBCXXRT)) +#if !defined(LIBCXXRT) && !defined(_LIBCPPABI_VERSION) std::bad_cast::bad_cast() _NOEXCEPT { } +std::bad_typeid::bad_typeid() _NOEXCEPT +{ +} + +#ifndef __GLIBCXX__ + std::bad_cast::~bad_cast() _NOEXCEPT { } @@ -36,10 +42,6 @@ std::bad_cast::what() const _NOEXCEPT return "std::bad_cast"; } -std::bad_typeid::bad_typeid() _NOEXCEPT -{ -} - std::bad_typeid::~bad_typeid() _NOEXCEPT { } @@ -67,4 +69,5 @@ std::bad_typeid::what() const _NOEXCEPT } #endif -#endif // _LIBCPPABI_VERSION +#endif // !__GLIBCXX__ +#endif // !LIBCXXRT && !_LIBCPPABI_VERSION diff --git a/system/lib/libcxx/valarray.cpp b/system/lib/libcxx/valarray.cpp index 2d8db52a..e4c9ed02 100644 --- a/system/lib/libcxx/valarray.cpp +++ b/system/lib/libcxx/valarray.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +#define _LIBCPP_EXTERN_TEMPLATE(...) extern template __VA_ARGS__; + #include "valarray" _LIBCPP_BEGIN_NAMESPACE_STD diff --git a/tests/cases/selectadd.ll b/tests/cases/selectadd.ll new file mode 100644 index 00000000..093032b8 --- /dev/null +++ b/tests/cases/selectadd.ll @@ -0,0 +1,29 @@ + +; ModuleID = 'tests/hello_world.bc' +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32-S128" +target triple = "i386-pc-linux-gnu" + +@.str = private unnamed_addr constant [15 x i8] c"hello, world!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*] + +; [#uses=0] +define i32 @main() { +entry: + br label %zero + +zero: + %.3.ph.i757 = phi i8* [ getelementptr ([15 x i8]* @.str, i32 0, i32 add (i32 xor (i32 ptrtoint (i8* getelementptr ([15 x i8]* @.str, i32 0, i32 select (i1 icmp ugt (i32 sub (i32 0, i32 add (i32 ptrtoint ([15 x i8]* @.str to i32), i32 25)), i32 xor (i32 ptrtoint ([15 x i8]* @.str to i32), i32 -1)), i32 sub (i32 0, i32 add (i32 ptrtoint ([15 x i8]* @.str to i32), i32 25)), i32 xor (i32 ptrtoint ([15 x i8]* @.str to i32), i32 -1))) to i32), i32 -1), i32 25)), %entry ], [ getelementptr ([15 x i8]* @.str, i32 0, i32 ptrtoint (i8* getelementptr ([15 x i8]* @.str, i32 0, i32 add (i32 sub (i32 0, i32 ptrtoint ([15 x i8]* @.str to i32)), i32 25)) to i32)), %other ] + + %retval = alloca i32, align 4 ; [#uses=1 type=i32*] + store i32 0, i32* %retval + %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0 type=i32] + br label %other + +other: + br i1 0, label %zero, label %last + +last: + ret i32 1 +} + +declare i32 @printf(i8*, ...) + diff --git a/tests/cases/storebigfloat.ll b/tests/cases/storebigfloat.ll new file mode 100644 index 00000000..c9995835 --- /dev/null +++ b/tests/cases/storebigfloat.ll @@ -0,0 +1,17 @@ + +@.str = private unnamed_addr constant [15 x i8] c"hello, world!\0A\00", align 1 ; [#uses=1 type=[15 x i8]*] + +; [#uses=0] +define i32 @main() { +entry: + %retval = alloca i32, align 4 ; [#uses=1 type=i32*] + %f = alloca float, align 4 + store float 1.000000e+10, float* %f, align 4 + store i32 0, i32* %retval + %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0 type=i32] + ret i32 1 +} + +; [#uses=1] +declare i32 @printf(i8*, ...) + diff --git a/tests/cubegeom.c b/tests/cubegeom.c index fac0da2b..96d56339 100644 --- a/tests/cubegeom.c +++ b/tests/cubegeom.c @@ -194,8 +194,14 @@ int main(int argc, char *argv[]) // sauer vertex data is apparently 0-12: V3F, 12: N1B, 16-24: T2F, 24-28: T2S, 28-32: C4B glVertexPointer(3, GL_FLOAT, 32, (void*)0); // all these apply to the ARRAY_BUFFER that is bound glTexCoordPointer(2, GL_FLOAT, 32, (void*)16); + glClientActiveTexture(GL_TEXTURE1); // XXX seems to be ignored in native build glTexCoordPointer(2, GL_SHORT, 32, (void*)24); + glGetIntegerv(GL_TEXTURE_COORD_ARRAY_SIZE, &tempInt); assert(tempInt == 2); + glGetIntegerv(GL_TEXTURE_COORD_ARRAY_TYPE, &tempInt); assert(tempInt == GL_SHORT); + glGetIntegerv(GL_TEXTURE_COORD_ARRAY_STRIDE, &tempInt); assert(tempInt == 32); + glGetPointerv(GL_TEXTURE_COORD_ARRAY_POINTER, &tempPtr); assert(tempPtr == (void *)24); + glClientActiveTexture(GL_TEXTURE0); // likely not needed, it is a cleanup glNormalPointer(GL_BYTE, 32, (void*)12); glColorPointer(4, GL_UNSIGNED_BYTE, 32, (void*)28); diff --git a/tests/emscripten_get_now.cpp b/tests/emscripten_get_now.cpp index 17aa7d32..5ededb23 100644 --- a/tests/emscripten_get_now.cpp +++ b/tests/emscripten_get_now.cpp @@ -14,10 +14,10 @@ int main() { // b) Values returned by emscripten_get_now() are strictly nondecreasing. // c) emscripten_get_now() is able to return sub-millisecond precision timer values. bool detected_good_timer_precision = false; - float smallest_delta = 0.f; + double smallest_delta = 0.f; for(int x = 0; x < 1000; ++x) { // Have several attempts to find a good small delta, i.e. give time to JS engine to warm up the code and so on. - float t = emscripten_get_now(); - float t2 = emscripten_get_now(); + double t = emscripten_get_now(); + double t2 = emscripten_get_now(); for(int i = 0; i < 100 && t == t2; ++i) { t2 = emscripten_get_now(); } diff --git a/tests/gles2_conformance.cpp b/tests/gles2_conformance.cpp new file mode 100644 index 00000000..80539f7f --- /dev/null +++ b/tests/gles2_conformance.cpp @@ -0,0 +1,76 @@ +#include "SDL/SDL.h" + +#include <GLES2/gl2.h> + +#include <stdio.h> +#include <string.h> + +int result = 1; // Success +#define assert(x) do { if (!(x)) {result = 0; printf("Assertion failure: %s in %s:%d!\n", #x, __FILE__, __LINE__); } } while(0) + +int main(int argc, char *argv[]) +{ + SDL_Surface *screen; + + // Slightly different SDL initialization + if ( SDL_Init(SDL_INIT_VIDEO) != 0 ) { + printf("Unable to initialize SDL: %s\n", SDL_GetError()); + return 1; + } + + screen = SDL_SetVideoMode( 640, 480, 16, SDL_OPENGL ); // *changed* + if ( !screen ) { + printf("Unable to set video mode: %s\n", SDL_GetError()); + return 1; + } + + // Test that code containing functions related to GLES2 binary shader API will successfully compile ad run + // (will be nonfunctional no-ops since WebGL doesn't have binary shaders) + GLuint vs = glCreateShader(GL_VERTEX_SHADER); + glShaderBinary(1, &vs, 0, 0, 0); + assert(glGetError() != GL_NO_ERROR); + + GLboolean b = GL_TRUE; + GLint i = -1; + GLfloat f = -1.f; + glGetBooleanv(GL_NUM_SHADER_BINARY_FORMATS, &b); + assert(glGetError() == GL_NO_ERROR); + assert(b == GL_FALSE); + glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &i); + assert(glGetError() == GL_NO_ERROR); + assert(i == 0); + glGetFloatv(GL_NUM_SHADER_BINARY_FORMATS, &f); + assert(glGetError() == GL_NO_ERROR); + assert(f == 0.f); + + // Currently testing that glGetIntegerv(GL_SHADER_BINARY_FORMATS) should be a no-op. + // The spec is somewhat vague here, equally as good could be to return GL_INVALID_ENUM here. + i = 123; + glGetIntegerv(GL_SHADER_BINARY_FORMATS, &i); + assert(glGetError() == GL_NO_ERROR); + assert(i == 0); + + // Spec does not say what to report on the following, but since GL_SHADER_BINARY_FORMATS is supposed + // to return a a pointer to an array representing a list, the pointer can't be converted to bool or float, + // so report a GL_INVALID_ENUM. + glGetBooleanv(GL_SHADER_BINARY_FORMATS, &b); + assert(glGetError() == GL_INVALID_ENUM); + + glGetFloatv(GL_SHADER_BINARY_FORMATS, &f); + assert(glGetError() == GL_INVALID_ENUM); + + // Test that we can query for shader compiler support. + glGetIntegerv(GL_SHADER_COMPILER, &i); + assert(glGetError() == GL_NO_ERROR); + assert(i != 0); + glGetBooleanv(GL_SHADER_COMPILER, &b); + assert(glGetError() == GL_NO_ERROR); + assert(b == GL_TRUE); + glGetFloatv(GL_SHADER_COMPILER, &f); + assert(glGetError() == GL_NO_ERROR); + assert(f == 1.f); + +#ifdef REPORT_RESULT + REPORT_RESULT(); +#endif +} diff --git a/tests/gles2_uniform_arrays.cpp b/tests/gles2_uniform_arrays.cpp index 84e394dc..7293f9a9 100644 --- a/tests/gles2_uniform_arrays.cpp +++ b/tests/gles2_uniform_arrays.cpp @@ -35,6 +35,15 @@ void RunTest(int testVariant) glBindAttribLocation(program, 0, "pos"); glLinkProgram(program); + // Also test that GL_ACTIVE_ATTRIBUTE_MAX_LENGTH and GL_ACTIVE_UNIFORM_MAX_LENGTH work. See https://github.com/kripken/emscripten/issues/1796. + GLint param; + glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, ¶m); + printf("active attrib max length: %d\n", param); + assert(param == 4); // "pos"+null terminator + glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, ¶m); + printf("active uniform max length: %d\n", param); + assert(param == 10); // "colors[0]"+null terminator + int color_loc = glGetUniformLocation(program, "color"); assert(color_loc != -1); diff --git a/tests/lua/Makefile b/tests/lua/Makefile index bd9515fd..9f0a2edd 100644 --- a/tests/lua/Makefile +++ b/tests/lua/Makefile @@ -51,8 +51,9 @@ R= $V.1 # Targets start here. all: $(PLAT) +# XXX Emscripten Added quotes to $(MAKE) to properly call make when the path contains spaces $(PLATS) clean: - cd src && $(MAKE) $@ + cd src && "$(MAKE)" $@ test: dummy src/lua -v diff --git a/tests/lua/src/Makefile b/tests/lua/src/Makefile index 401e7367..a9cf0911 100644 --- a/tests/lua/src/Makefile +++ b/tests/lua/src/Makefile @@ -59,8 +59,9 @@ o: $(ALL_O) a: $(ALL_A) +# XXX EMSCRIPTEN: add AR_ARGS $(LUA_A): $(BASE_O) - $(AR) $(AR_ARGS) $@ $(BASE_O) # XXX EMSCRIPTEN: add AR_ARGS + $(AR) $(AR_ARGS) $@ $(BASE_O) $(RANLIB) $@ $(LUA_T): $(LUA_O) $(LUA_A) diff --git a/tests/mmap_file.c b/tests/mmap_file.c new file mode 100644 index 00000000..6eed95e0 --- /dev/null +++ b/tests/mmap_file.c @@ -0,0 +1,27 @@ +#include <stdio.h> +#include <sys/mman.h> +#include <emscripten.h> +#include <string.h> +#include <assert.h> + +int main() { + printf("*\n"); + FILE *f = fopen("data.dat", "r"); + char *m; + m = (char*)mmap(NULL, 9000, PROT_READ, MAP_PRIVATE, fileno(f), 0); + for (int i = 0; i < 20; i++) putchar(m[i]); + assert(!strncmp(m, "data from the file .", 20)); + munmap(m, 9000); + printf("\n"); + m = (char*)mmap(NULL, 9000, PROT_READ, MAP_PRIVATE, fileno(f), 5); + for (int i = 0; i < 20; i++) putchar(m[i]); + assert(!strncmp(m, "from the file ......", 20)); + munmap(m, 9000); + printf("\n*\n"); + +#ifdef REPORT_RESULT + int result = 1; + REPORT_RESULT(); +#endif + return 0; +} diff --git a/tests/runner.py b/tests/runner.py index 867f7113..8c4a9abf 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -36,7 +36,7 @@ except: # Core test runner class, shared between normal tests and benchmarks checked_sanity = False -test_modes = ['default', 'o1', 'o2', 'asm1', 'asm2', 'asm2g', 'asm2x86', 's_0_0', 's_0_1'] +test_modes = ['default', 'o1', 'o2', 'asm1', 'asm2', 'asm2f', 'asm2g', 'asm2x86', 's_0_0', 's_0_1'] test_index = 0 class RunnerCore(unittest.TestCase): diff --git a/tests/sdl_canvas_palette.c b/tests/sdl_canvas_palette.c index 316aa44a..361f71a6 100644 --- a/tests/sdl_canvas_palette.c +++ b/tests/sdl_canvas_palette.c @@ -42,7 +42,7 @@ int main() { //changing green color //to yellow pal[1].r = 255; - SDL_SetColors(screen, pal, 1, 1); + SDL_SetColors(screen, &pal[1], 1, 1); { SDL_Rect rect = { 300, 200, 300, 200 }; diff --git a/tests/sdl_joystick.c b/tests/sdl_joystick.c new file mode 100644 index 00000000..50802c31 --- /dev/null +++ b/tests/sdl_joystick.c @@ -0,0 +1,124 @@ +#include <stdio.h> +#include <SDL/SDL.h> +#include <SDL/SDL_ttf.h> +#include <assert.h> +#include <string.h> +#include <emscripten.h> + +int result = 1; + +void assertJoystickEvent(int expectedGamepad, int expectedType, int expectedIndex, int expectedValue) { + SDL_Event event; + while(1) { + // Loop ends either when assertion fails (we run out of events), or we find + // the event we're looking for. + assert(SDL_PollEvent(&event) == 1); + if (event.type != expectedType) { + continue; + } + switch(event.type) { + case SDL_JOYAXISMOTION: { + assert(event.jaxis.which == expectedGamepad); + assert(event.jaxis.axis == expectedIndex); + assert(event.jaxis.value == expectedValue); + break; + } + case SDL_JOYBUTTONUP: case SDL_JOYBUTTONDOWN: { + assert(event.jbutton.which == expectedGamepad); + assert(event.jbutton.button == expectedIndex); + assert(event.jbutton.state == expectedValue); + break; + } + } + // Break out of while loop. + break; + } +} + +void assertNoJoystickEvent() { + SDL_Event event; + while(SDL_PollEvent(&event)) { + switch(event.type) { + case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONUP: case SDL_JOYAXISMOTION: { + // Fail. + assert(0); + } + } + } +} + +void main_2(void* arg); + +int main() { + SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK); + SDL_Surface *screen = SDL_SetVideoMode(600, 450, 32, SDL_HWSURFACE); + emscripten_async_call(main_2, NULL, 3000); // avoid startup delays and intermittent errors + return 0; +} + +void main_2(void* arg) { + // TODO: At the moment, we only support joystick support through polling. + emscripten_run_script("window.addNewGamepad('Pad Thai', 4, 16)"); + emscripten_run_script("window.addNewGamepad('Pad Kee Mao', 0, 4)"); + // Check that the joysticks exist properly. + assert(SDL_NumJoysticks() == 2); + assert(!SDL_JoystickOpened(0)); + assert(!SDL_JoystickOpened(1)); + SDL_Joystick* pad1 = SDL_JoystickOpen(0); + assert(SDL_JoystickOpened(0)); + assert(SDL_JoystickIndex(pad1) == 0); + assert(strncmp(SDL_JoystickName(0), "Pad Thai", 9) == 0); + assert(strncmp(SDL_JoystickName(1), "Pad Kee Mao", 12) == 0); + assert(SDL_JoystickNumAxes(pad1) == 4); + assert(SDL_JoystickNumButtons(pad1) == 16); + + // Button events. + emscripten_run_script("window.simulateGamepadButtonDown(0, 1)"); + // We didn't tell SDL to automatically update this joystick's state. + assertNoJoystickEvent(); + SDL_JoystickUpdate(); + assertJoystickEvent(0, SDL_JOYBUTTONDOWN, 1, SDL_PRESSED); + assert(SDL_JoystickGetButton(pad1, 1) == 1); + // Enable automatic updates. + SDL_JoystickEventState(SDL_ENABLE); + assert(SDL_JoystickEventState(SDL_QUERY) == SDL_ENABLE); + emscripten_run_script("window.simulateGamepadButtonUp(0, 1)"); + assertJoystickEvent(0, SDL_JOYBUTTONUP, 1, SDL_RELEASED); + assert(SDL_JoystickGetButton(pad1, 1) == 0); + // No button change: Should not result in a new event. + emscripten_run_script("window.simulateGamepadButtonUp(0, 1)"); + assertNoJoystickEvent(); + // Joystick 1 is not opened; should not result in a new event. + emscripten_run_script("window.simulateGamepadButtonDown(1, 1)"); + assertNoJoystickEvent(); + + // Joystick wiggling + emscripten_run_script("window.simulateAxisMotion(0, 0, 1)"); + assertJoystickEvent(0, SDL_JOYAXISMOTION, 0, 32767); + assert(SDL_JoystickGetAxis(pad1, 0) == 32767); + emscripten_run_script("window.simulateAxisMotion(0, 0, 0)"); + assertJoystickEvent(0, SDL_JOYAXISMOTION, 0, 0); + assert(SDL_JoystickGetAxis(pad1, 0) == 0); + emscripten_run_script("window.simulateAxisMotion(0, 1, -1)"); + assertJoystickEvent(0, SDL_JOYAXISMOTION, 1, -32768); + assert(SDL_JoystickGetAxis(pad1, 1) == -32768); + emscripten_run_script("window.simulateAxisMotion(0, 1, -1)"); + // No joystick change: Should not result in a new event. + assertNoJoystickEvent(); + // Joystick 1 is not opened; should not result in a new event. + emscripten_run_script("window.simulateAxisMotion(1, 1, -1)"); + assertNoJoystickEvent(); + + SDL_JoystickClose(pad1); + assert(!SDL_JoystickOpened(0)); + + // Joystick 0 is closed; we should not process any new gamepad events from it. + emscripten_run_script("window.simulateGamepadButtonDown(0, 1)"); + assertNoJoystickEvent(); + + // End test. + result = 2; + printf("Test passed!\n"); + REPORT_RESULT(); +} + diff --git a/tests/sockets/test_getaddrinfo.c b/tests/sockets/test_getaddrinfo.c index 717a9ae7..1f912c69 100644 --- a/tests/sockets/test_getaddrinfo.c +++ b/tests/sockets/test_getaddrinfo.c @@ -174,6 +174,7 @@ int main() { assert(servinfo->ai_family == AF_INET); assert(servinfo->ai_socktype == SOCK_STREAM); assert(sa4->sin_port == ntohs(89)); + freeaddrinfo(servinfo); // test non-numeric host with AF_INET6 memset(&hints, 0, sizeof(hints)); @@ -189,6 +190,65 @@ int main() { *((uint32_t*)&(sa6->sin6_addr)+2) != 0 || *((uint32_t*)&(sa6->sin6_addr)+3) != 0); assert(sa6->sin6_port == ntohs(90)); + freeaddrinfo(servinfo); + + // test with NULL hints + // Specifying hints as NULL is equivalent to setting ai_socktype and ai_protocol to 0; + // ai_family to AF_UNSPEC; and ai_flags to (AI_V4MAPPED | AI_ADDRCONFIG) + // N.B. with NULL hints getaddrinfo should really be passing back multiple addrinfo structures in a + // linked list with next values given in ai_next. The current implementation doesn't do that yet but the + // following tests have assert(servinfo->ai_next == NULL) so that they will fail when multiple values do + // eventually get implemented, so we know to improve the tests then to cope with multiple values. + + // test numeric host + err = getaddrinfo("1.2.3.4", "85", NULL, &servinfo); + assert(!err); + sa4 = ((struct sockaddr_in*)servinfo->ai_addr); + assert(servinfo->ai_family == AF_INET); + assert(servinfo->ai_socktype == SOCK_STREAM); + assert(servinfo->ai_protocol == IPPROTO_TCP); + assert(sa4->sin_port == ntohs(85)); + assert(servinfo->ai_next == NULL); + freeaddrinfo(servinfo); + + // test non-numeric host + err = getaddrinfo("www.mozilla.org", "89", NULL, &servinfo); + assert(!err); + sa4 = ((struct sockaddr_in*)servinfo->ai_addr); + assert(servinfo->ai_family == AF_INET); + assert(servinfo->ai_socktype == SOCK_STREAM); + assert(servinfo->ai_protocol == IPPROTO_TCP); + assert(sa4->sin_port == ntohs(89)); + assert(servinfo->ai_next == NULL); + freeaddrinfo(servinfo); + + // test loopback resolution + err = getaddrinfo(NULL, "80", NULL, &servinfo); + assert(!err); + sa4 = ((struct sockaddr_in*)servinfo->ai_addr); + assert(servinfo->ai_family == AF_INET); + assert(servinfo->ai_socktype == SOCK_STREAM); + assert(servinfo->ai_protocol == IPPROTO_TCP); + assert(sa4->sin_port == ntohs(80)); + assert(servinfo->ai_next == NULL); + freeaddrinfo(servinfo); + + // test gai_strerror + assert(strncmp(gai_strerror(0), "Success", 256) == 0); + assert(strncmp(gai_strerror(EAI_BADFLAGS), "Invalid value for 'ai_flags' field", 256) == 0); + assert(strncmp(gai_strerror(EAI_NONAME), "NAME or SERVICE is unknown", 256) == 0); + assert(strncmp(gai_strerror(EAI_AGAIN), "Temporary failure in name resolution", 256) == 0); + assert(strncmp(gai_strerror(EAI_FAIL), "Non-recoverable failure in name res", 256) == 0); + assert(strncmp(gai_strerror(EAI_FAMILY), "'ai_family' not supported", 256) == 0); + assert(strncmp(gai_strerror(EAI_SOCKTYPE), "'ai_socktype' not supported", 256) == 0); + assert(strncmp(gai_strerror(EAI_SERVICE), "SERVICE not supported for 'ai_socktype'", 256) == 0); + assert(strncmp(gai_strerror(EAI_MEMORY), "Memory allocation failure", 256) == 0); + assert(strncmp(gai_strerror(EAI_SYSTEM), "System error returned in 'errno'", 256) == 0); + assert(strncmp(gai_strerror(EAI_OVERFLOW), "Argument buffer overflow", 256) == 0); + assert(strncmp(gai_strerror(-5), "Unknown error", 256) == 0); + assert(strncmp(gai_strerror(-9), "Unknown error", 256) == 0); + assert(strncmp(gai_strerror(-13), "Unknown error", 256) == 0); + assert(strncmp(gai_strerror(-100), "Unknown error", 256) == 0); puts("success"); diff --git a/tests/test_benchmark.py b/tests/test_benchmark.py index e9cfee52..63e0041f 100644 --- a/tests/test_benchmark.py +++ b/tests/test_benchmark.py @@ -13,11 +13,6 @@ from tools.shared import * DEFAULT_ARG = '4' TEST_REPS = 2 -TOTAL_TESTS = 8 - -tests_done = 0 -total_times = map(lambda x: 0., range(TOTAL_TESTS)) -total_native_times = map(lambda x: 0., range(TOTAL_TESTS)) class benchmark(RunnerCore): save_dir = True @@ -119,15 +114,15 @@ process(sys.argv[1]) try_delete(final_filename) output = Popen([PYTHON, EMCC, filename, #'-O3', '-O2', '-s', 'DOUBLE_MODE=0', '-s', 'PRECISE_I64_MATH=0', - '--llvm-lto', '3', '--memory-init-file', '0', '--js-transform', 'python hardcode.py', + '--memory-init-file', '0', '--js-transform', 'python hardcode.py', '-s', 'TOTAL_MEMORY=128*1024*1024', '--closure', '1', + #'-s', 'PRECISE_F32=1', #'-g', '-o', final_filename] + shared_args + emcc_args, stdout=PIPE, stderr=self.stderr_redirect).communicate() assert os.path.exists(final_filename), 'Failed to compile file: ' + output[0] # Run JS - global total_times, tests_done times = [] for i in range(reps): start = time.time() @@ -141,7 +136,6 @@ process(sys.argv[1]) else: curr = output_parser(js_output) times.append(curr) - total_times[tests_done] += curr if i == 0: # Sanity check on output self.assertContained(expected_output, js_output) @@ -152,7 +146,6 @@ process(sys.argv[1]) else: shutil.copyfile(native_exec, filename + '.native') shutil.copymode(native_exec, filename + '.native') - global total_native_times native_times = [] for i in range(reps): start = time.time() @@ -165,15 +158,9 @@ process(sys.argv[1]) else: curr = output_parser(native_output) native_times.append(curr) - total_native_times[tests_done] += curr self.print_stats(times, native_times, reps=reps) - #tests_done += 1 - #if tests_done == TOTAL_TESTS: - # print 'Total stats:', - # self.print_stats(total_times, total_native_times, last=True) - def test_primes(self): src = r''' #include<stdio.h> @@ -428,10 +415,15 @@ process(sys.argv[1]) src = open(path_from_root('tests', 'life.c'), 'r').read() self.do_benchmark('life', src, '''--------------------------------''', shared_args=['-std=c99'], force_c=True) - def test_linpack(self): + def test_linpack_double(self): def output_parser(output): return 100.0/float(re.search('Unrolled Double Precision +([\d\.]+) Mflops', output).group(1)) - self.do_benchmark('linpack', open(path_from_root('tests', 'linpack.c')).read(), '''Unrolled Double Precision''', force_c=True, output_parser=output_parser) + self.do_benchmark('linpack_double', open(path_from_root('tests', 'linpack.c')).read(), '''Unrolled Double Precision''', force_c=True, output_parser=output_parser) + + def test_linpack_float(self): # TODO: investigate if this might benefit from -ffast-math in LLVM 3.3+ which has fast math stuff in LLVM IR + def output_parser(output): + return 100.0/float(re.search('Unrolled Single Precision +([\d\.]+) Mflops', output).group(1)) + self.do_benchmark('linpack_float', open(path_from_root('tests', 'linpack.c')).read(), '''Unrolled Single Precision''', force_c=True, output_parser=output_parser, shared_args=['-DSP']) def test_zzz_java_nbody(self): # tests xmlvm compiled java, including bitcasts of doubles, i64 math, etc. args = [path_from_root('tests', 'nbody-java', x) for x in os.listdir(path_from_root('tests', 'nbody-java')) if x.endswith('.c')] + \ @@ -504,4 +496,4 @@ process(sys.argv[1]) native_args = native_lib + ['-I' + path_from_root('tests', 'bullet', 'src'), '-I' + path_from_root('tests', 'bullet', 'Demos', 'Benchmarks')] - self.do_benchmark('bullet', src, '\nok.\n', emcc_args=emcc_args, native_args=native_args)
\ No newline at end of file + self.do_benchmark('bullet', src, '\nok.\n', emcc_args=emcc_args, native_args=native_args) diff --git a/tests/test_browser.py b/tests/test_browser.py index 2ff9106b..65bccb38 100644 --- a/tests/test_browser.py +++ b/tests/test_browser.py @@ -338,7 +338,7 @@ If manually bisecting: ("somefile.txt@/directory/file.txt", "/directory/file.txt"), ("somefile.txt@/directory/file.txt", "directory/file.txt"), (absolute_src_path + "@/directory/file.txt", "directory/file.txt")] - + for test in test_cases: (srcpath, dstpath) = test print 'Testing', srcpath, dstpath @@ -346,6 +346,11 @@ If manually bisecting: Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--preload-file', srcpath, '-o', 'page.html']).communicate() self.run_browser('page.html', 'You should see |load me right before|.', '/report_result?1') + # Test that '--no-heap-copy' works. + make_main('somefile.txt') + Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'main.cpp'), '--preload-file', 'somefile.txt', '--no-heap-copy', '-o', 'page.html']).communicate() + self.run_browser('page.html', 'You should see |load me right before|.', '/report_result?1') + # By absolute path make_main('somefile.txt') # absolute becomes relative @@ -869,6 +874,82 @@ keydown(100);keyup(100); // trigger the end def test_glut_wheelevents(self): self.btest('glut_wheelevents.c', '1') + def test_sdl_joystick_1(self): + # Generates events corresponding to the Working Draft of the HTML5 Gamepad API. + # http://www.w3.org/TR/2012/WD-gamepad-20120529/#gamepad-interface + open(os.path.join(self.get_dir(), 'pre.js'), 'w').write(''' + var gamepads = []; + // Spoof this function. + navigator['getGamepads'] = function() { + return gamepads; + }; + window['addNewGamepad'] = function(id, numAxes, numButtons) { + var index = gamepads.length; + gamepads.push({ + axes: new Array(numAxes), + buttons: new Array(numButtons), + id: id, + index: index + }); + var i; + for (i = 0; i < numAxes; i++) gamepads[index].axes[i] = 0; + for (i = 0; i < numButtons; i++) gamepads[index].buttons[i] = 0; + }; + window['simulateGamepadButtonDown'] = function (index, button) { + gamepads[index].buttons[button] = 1; + }; + window['simulateGamepadButtonUp'] = function (index, button) { + gamepads[index].buttons[button] = 0; + }; + window['simulateAxisMotion'] = function (index, axis, value) { + gamepads[index].axes[axis] = value; + }; + ''') + open(os.path.join(self.get_dir(), 'sdl_joystick.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'sdl_joystick.c')).read())) + + Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'sdl_joystick.c'), '-O2', '--minify', '0', '-o', 'page.html', '--pre-js', 'pre.js']).communicate() + self.run_browser('page.html', '', '/report_result?2') + + def test_sdl_joystick_2(self): + # Generates events corresponding to the Editor's Draft of the HTML5 Gamepad API. + # https://dvcs.w3.org/hg/gamepad/raw-file/default/gamepad.html#idl-def-Gamepad + open(os.path.join(self.get_dir(), 'pre.js'), 'w').write(''' + var gamepads = []; + // Spoof this function. + navigator['getGamepads'] = function() { + return gamepads; + }; + window['addNewGamepad'] = function(id, numAxes, numButtons) { + var index = gamepads.length; + gamepads.push({ + axes: new Array(numAxes), + buttons: new Array(numButtons), + id: id, + index: index + }); + var i; + for (i = 0; i < numAxes; i++) gamepads[index].axes[i] = 0; + // Buttons are objects + for (i = 0; i < numButtons; i++) gamepads[index].buttons[i] = { pressed: false, value: 0 }; + }; + // FF mutates the original objects. + window['simulateGamepadButtonDown'] = function (index, button) { + gamepads[index].buttons[button].pressed = true; + gamepads[index].buttons[button].value = 1; + }; + window['simulateGamepadButtonUp'] = function (index, button) { + gamepads[index].buttons[button].pressed = false; + gamepads[index].buttons[button].value = 0; + }; + window['simulateAxisMotion'] = function (index, axis, value) { + gamepads[index].axes[axis] = value; + }; + ''') + open(os.path.join(self.get_dir(), 'sdl_joystick.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'sdl_joystick.c')).read())) + + Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'sdl_joystick.c'), '-O2', '--minify', '0', '-o', 'page.html', '--pre-js', 'pre.js']).communicate() + self.run_browser('page.html', '', '/report_result?2') + def test_webgl_context_attributes(self): # Javascript code to check the attributes support we want to test in the WebGL implementation # (request the attribute, create a context and check its value afterwards in the context attributes). @@ -1066,6 +1147,12 @@ keydown(100);keyup(100); // trigger the end Popen([PYTHON, EMCC, '-O2', os.path.join(self.get_dir(), 'glfw.c'), '-o', 'page.html', '-s', 'LEGACY_GL_EMULATION=1']).communicate() self.run_browser('page.html', '', '/report_result?1') + def test_egl(self): + open(os.path.join(self.get_dir(), 'test_egl.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'test_egl.c')).read())) + + Popen([PYTHON, EMCC, '-O2', os.path.join(self.get_dir(), 'test_egl.c'), '-o', 'page.html']).communicate() + self.run_browser('page.html', '', '/report_result?1') + def test_egl_width_height(self): open(os.path.join(self.get_dir(), 'test_egl_width_height.c'), 'w').write(self.with_report_result(open(path_from_root('tests', 'test_egl_width_height.c')).read())) @@ -1362,6 +1449,9 @@ keydown(100);keyup(100); // trigger the end # def test_gles2_uniform_arrays(self): # self.btest('gles2_uniform_arrays.cpp', args=['-s', 'GL_ASSERTIONS=1'], expected=['1']) + def test_gles2_conformance(self): + self.btest('gles2_conformance.cpp', args=['-s', 'GL_ASSERTIONS=1'], expected=['1']) + def test_matrix_identity(self): self.btest('gl_matrix_identity.c', expected=['-1882984448', '460451840'], args=['-s', 'LEGACY_GL_EMULATION=1']) @@ -1566,3 +1656,7 @@ keydown(100);keyup(100); // trigger the end Popen([PYTHON, EMCC, path_from_root('tests', 'browser_module.cpp'), '-o', 'module.js', '-O2', '-s', 'SIDE_MODULE=1', '-s', 'DLOPEN_SUPPORT=1', '-s', 'EXPORTED_FUNCTIONS=["_one", "_two"]']).communicate() self.btest('browser_main.cpp', args=['-O2', '-s', 'MAIN_MODULE=1', '-s', 'DLOPEN_SUPPORT=1'], expected='8') + def test_mmap_file(self): + open(self.in_dir('data.dat'), 'w').write('data from the file ' + ('.' * 9000)) + for extra_args in [[], ['--no-heap-copy']]: + self.btest(path_from_root('tests', 'mmap_file.c'), expected='1', args=['--preload-file', 'data.dat'] + extra_args) diff --git a/tests/test_core.py b/tests/test_core.py index 9f734c0e..545bb63f 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -882,6 +882,32 @@ nada ''' self.do_run(src, 'OK!\n'); + def test_float32_precise(self): + Settings.PRECISE_F32 = 1 + + src = r''' + #include <stdio.h> + + int main(int argc, char **argv) { + float x = 1.23456789123456789; + float y = 5.20456089123406709; + while (argc > 10 || argc % 19 == 15) { + // confuse optimizer + x /= y; + y = 2*y - 1; + argc--; + } + x = x - y; + y = 3*y - x/2; + x = x*y; + y += 0.000000000123123123123; + x -= y/7.654; + printf("\n%.20f, %.20f\n", x, y); + return 0; + } + ''' + self.do_run(src, '\n-72.16590881347656250000, 17.59867858886718750000\n') + def test_negative_zero(self): src = r''' #include <stdio.h> @@ -1490,7 +1516,7 @@ f6: nan #include <stdio.h> #include <stdlib.h> #include <cmath> - int main() + int main(int argc, char **argv) { printf("*%.2f,%.2f,%d", M_PI, -M_PI, (1/0.0) > 1e300); // could end up as infinity, or just a very very big number printf(",%d", isfinite(NAN) != 0); @@ -1512,11 +1538,15 @@ f6: nan sincosf(0.0, &fsine, &fcosine); printf(",%1.1f", fsine); printf(",%1.1f", fcosine); + fsine = sinf(1.1 + argc - 1); + fcosine = cosf(1.1 + argc - 1); + printf(",%1.1f", fsine); + printf(",%1.1f", fcosine); printf("*\\n"); return 0; } ''' - self.do_run(src, '*3.14,-3.14,1,0,0,0,1,0,1,1,0,2,3,0.0,1.0,0.0,1.0*') + self.do_run(src, '*3.14,-3.14,1,0,0,0,1,0,1,1,0,2,3,0.0,1.0,0.0,1.0,0.9,0.5*') def test_erf(self): src = ''' @@ -2921,7 +2951,7 @@ Exiting setjmp function, level: 0, prev_jmp: -1 ''') self.emcc_args += ['--pre-js', 'pre.js'] - self.do_run(src, '''reported\nexit(1) called\nExit Status: 1\npostRun\nok.\n''') + self.do_run(src, '''reported\nExit Status: 1\npostRun\nok.\n''') def test_class(self): src = ''' @@ -3857,7 +3887,6 @@ def process(filename): self.do_run(open(path_from_root('tests', 'emscripten_get_now.cpp')).read(), 'Timer resolution is good.') def test_inlinejs(self): - if Settings.ASM_JS: Settings.ASM_JS = 2 # skip validation, asm does not support random code if not self.is_le32(): return self.skip('le32 needed for inline js') src = r''' #include <stdio.h> @@ -3865,6 +3894,10 @@ def process(filename): double get() { double ret = 0; __asm __volatile__("Math.abs(-12/3.3)":"=r"(ret)); // write to a variable + asm("#comment1"); + asm volatile("#comment2"); + asm volatile("#comment3\n" + "#comment4\n"); return ret; } @@ -3883,9 +3916,11 @@ def process(filename): ''' self.do_run(src, 'Inline JS is very cool\n3.64\n') # TODO 1\n2\n3\n1\n2\n3\n') + if self.emcc_args == []: # opts will eliminate the comments + out = open('src.cpp.o.js').read() + for i in range(1, 5): assert ('comment%d' % i) in out def test_inlinejs2(self): - if Settings.ASM_JS: Settings.ASM_JS = 2 # skip validation, asm does not support random code if not self.is_le32(): return self.skip('le32 needed for inline js') src = r''' #include <stdio.h> @@ -8373,9 +8408,14 @@ extern "C" { if self.emcc_args is None: return self.skip('requires emcc') results = [ (1,'''GG*ctt**tgagc*'''), (20,'''GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTT*cttBtatcatatgctaKggNcataaaSatgtaaaDcDRtBggDtctttataattcBgtcg**tacgtgtagcctagtgtttgtgttgcgttatagtctatttgtggacacagtatggtcaaa**tgacgtcttttgatctgacggcgttaacaaagatactctg*'''), (50,'''GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGGGAGGCCGAGGCGGGCGGA*TCACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACAT*cttBtatcatatgctaKggNcataaaSatgtaaaDcDRtBggDtctttataattcBgtcg**tactDtDagcctatttSVHtHttKtgtHMaSattgWaHKHttttagacatWatgtRgaaa**NtactMcSMtYtcMgRtacttctWBacgaa**agatactctgggcaacacacatacttctctcatgttgtttcttcggacctttcataacct**ttcctggcacatggttagctgcacatcacaggattgtaagggtctagtggttcagtgagc**ggaatatcattcgtcggtggtgttaatctatctcggtgtagcttataaatgcatccgtaa**gaatattatgtttatttgtcggtacgttcatggtagtggtgtcgccgatttagacgtaaa**ggcatgtatg*''') ] - for i, j in results: - src = open(path_from_root('tests', 'fasta.cpp'), 'r').read() - self.do_run(src, j, [str(i)], lambda x, err: x.replace('\n', '*'), no_build=i>1) + for precision in [0, 1, 2]: + Settings.PRECISE_F32 = precision + for t in ['float', 'double']: + print precision, t + src = open(path_from_root('tests', 'fasta.cpp'), 'r').read().replace('double', t) + for i, j in results: + self.do_run(src, j, [str(i)], lambda x, err: x.replace('\n', '*'), no_build=i>1) + shutil.copyfile('src.cpp.o.js', '%d_%s.js' % (precision, t)) def test_whets(self): if not Settings.ASM_JS: return self.skip('mainly a test for asm validation here') @@ -8637,30 +8677,13 @@ void*:16 def test_mmap_file(self): if self.emcc_args is None: return self.skip('requires emcc') - self.emcc_args += ['--embed-file', 'data.dat'] - - open(self.in_dir('data.dat'), 'w').write('data from the file ' + ('.' * 9000)) + for extra_args in [[], ['--no-heap-copy']]: + self.emcc_args += ['--embed-file', 'data.dat'] + extra_args - src = r''' - #include <stdio.h> - #include <sys/mman.h> + open(self.in_dir('data.dat'), 'w').write('data from the file ' + ('.' * 9000)) - int main() { - printf("*\n"); - FILE *f = fopen("data.dat", "r"); - char *m; - m = (char*)mmap(NULL, 9000, PROT_READ, MAP_PRIVATE, fileno(f), 0); - for (int i = 0; i < 20; i++) putchar(m[i]); - munmap(m, 9000); - printf("\n"); - m = (char*)mmap(NULL, 9000, PROT_READ, MAP_PRIVATE, fileno(f), 5); - for (int i = 0; i < 20; i++) putchar(m[i]); - munmap(m, 9000); - printf("\n*\n"); - return 0; - } - ''' - self.do_run(src, '*\ndata from the file .\nfrom the file ......\n*\n') + src = open(path_from_root('tests', 'mmap_file.c')).read() + self.do_run(src, '*\ndata from the file .\nfrom the file ......\n*\n') def test_cubescript(self): if self.emcc_args is None: return self.skip('requires emcc') @@ -8725,7 +8748,7 @@ _mm_setzero_ps(void) int main(int argc, char **argv) { float data[8]; - for (int i = 0; i < 32; i++) data[i] = (1+i+argc)*(2+i+argc*argc); + for (int i = 0; i < 32; i++) data[i] = (1+i+argc)*(2+i+argc*argc); // confuse optimizer { float32x4 *a = (float32x4*)&data[0]; float32x4 *b = (float32x4*)&data[4]; @@ -8750,6 +8773,11 @@ int main(int argc, char **argv) { e = c+d; f = c-d; printf("5uints! %d, %d, %d, %d %d, %d, %d, %d\n", e[0], e[1], e[2], e[3], f[0], f[1], f[2], f[3]); + e = c&d; + f = c|d; + e = ~c&d; + f = c^d; + printf("5uintops! %d, %d, %d, %d %d, %d, %d, %d\n", e[0], e[1], e[2], e[3], f[0], f[1], f[2], f[3]); } { float32x4 c, d, e, f; @@ -8769,6 +8797,7 @@ int main(int argc, char **argv) { zeros 0, 0, 0, 0 4uints! 1086324736, 1094713344, 1101004800, 1106247680 1109917696, 1113587712, 1116733440, 1119092736 5uints! -2098724864, -2086666240, -2077229056, -2069626880 -23592960, -18874368, -15728640, -12845056 +5uintops! 36175872, 35651584, 34603008, 33816576 48758784, 52428800, 53477376, 54788096 6floats! -9, 0, 4, 9 -2, -12, 14, 10 ''') @@ -8916,6 +8945,7 @@ def process(filename): def test_sqlite(self): # gcc -O3 -I/home/alon/Dev/emscripten/tests/sqlite -ldl src.c if self.emcc_args is None: return self.skip('Very slow without ta2, and we would also need to include dlmalloc manually without emcc') + if not self.is_le32(): return self.skip('fails on x86 due to a legalization issue on llvm 3.3') if Settings.QUANTUM_SIZE == 1: return self.skip('TODO FIXME') self.banned_js_engines = [NODE_JS] # OOM in older node @@ -9519,7 +9549,7 @@ def process(filename): Settings.DEAD_FUNCTIONS = [] # Run the same code with argc that uses the dead function, see abort - test(('missing function: unused'), args=['a', 'b'], no_build=True) + test(('dead function: unused'), args=['a', 'b'], no_build=True) # Normal stuff run_all('normal', r''' @@ -10531,7 +10561,7 @@ def process(filename): Module.callMain(); ''') self.emcc_args += ['-s', 'INVOKE_RUN=0', '--post-js', 'post.js'] - self.do_run(src, 'hello, world!\nexit(118) called\ncleanup\nI see exit status: 118') + self.do_run(src, 'hello, world!\ncleanup\nI see exit status: 118') def test_gc(self): if self.emcc_args == None: return self.skip('needs ta2') @@ -10761,6 +10791,7 @@ o2 = make_run("o2", compiler=CLANG, emcc_args=["-O2", "-s", "ASM_JS=0", "-s", "J # asm.js asm1 = make_run("asm1", compiler=CLANG, emcc_args=["-O1"]) asm2 = make_run("asm2", compiler=CLANG, emcc_args=["-O2"]) +asm2f = make_run("asm2f", compiler=CLANG, emcc_args=["-O2", "-s", "PRECISE_F32=1"]) asm2g = make_run("asm2g", compiler=CLANG, emcc_args=["-O2", "-g", "-s", "ASSERTIONS=1", "--memory-init-file", "1", "-s", "CHECK_HEAP_ALIGN=1"]) asm2x86 = make_run("asm2x86", compiler=CLANG, emcc_args=["-O2", "-g", "-s", "CHECK_HEAP_ALIGN=1"], env={"EMCC_LLVM_TARGET": "i386-pc-linux-gnu"}) diff --git a/tests/test_egl.c b/tests/test_egl.c new file mode 100644 index 00000000..5864a797 --- /dev/null +++ b/tests/test_egl.c @@ -0,0 +1,73 @@ +#include <stdio.h> +#include <EGL/egl.h> + +int result = 1; // Success +#define assert(x) do { if (!(x)) {result = 0; printf("Assertion failure: %s in %s:%d!\n", #x, __FILE__, __LINE__); } } while(0) + +int main(int argc, char *argv[]) +{ + EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); + assert(display != EGL_NO_DISPLAY); + assert(eglGetError() == EGL_SUCCESS); + + EGLint major = 0, minor = 0; + EGLBoolean ret = eglInitialize(display, &major, &minor); + assert(eglGetError() == EGL_SUCCESS); + assert(ret == EGL_TRUE); + assert(major * 10000 + minor >= 10004); + + EGLint numConfigs; + ret = eglGetConfigs(display, NULL, 0, &numConfigs); + assert(eglGetError() == EGL_SUCCESS); + assert(ret == EGL_TRUE); + + EGLint attribs[] = { + EGL_RED_SIZE, 5, + EGL_GREEN_SIZE, 6, + EGL_BLUE_SIZE, 5, + EGL_NONE + }; + EGLConfig config; + ret = eglChooseConfig(display, attribs, &config, 1, &numConfigs); + assert(eglGetError() == EGL_SUCCESS); + assert(ret == EGL_TRUE); + + EGLNativeWindowType dummyWindow; + EGLSurface surface = eglCreateWindowSurface(display, config, dummyWindow, NULL); + assert(eglGetError() == EGL_SUCCESS); + assert(surface != 0); + + EGLint contextAttribs[] = + { + EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_NONE + }; + EGLContext context = eglCreateContext(display, config, NULL, contextAttribs); + assert(eglGetError() == EGL_SUCCESS); + assert(context != 0); + + assert(eglGetCurrentContext() == 0); // Creating a context does not yet activate it. + assert(eglGetError() == EGL_SUCCESS); + + ret = eglMakeCurrent(display, surface, surface, context); + assert(eglGetError() == EGL_SUCCESS); + assert(ret == EGL_TRUE); + assert(eglGetCurrentContext() == context); + assert(eglGetCurrentSurface(EGL_READ) == surface); + assert(eglGetCurrentSurface(EGL_DRAW) == surface); + + ret = eglMakeCurrent(display, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + assert(eglGetError() == EGL_SUCCESS); + assert(ret == EGL_TRUE); + assert(eglGetCurrentContext() == EGL_NO_CONTEXT); + assert(eglGetCurrentSurface(EGL_READ) == EGL_NO_SURFACE); + assert(eglGetCurrentSurface(EGL_DRAW) == EGL_NO_SURFACE); + + ret = eglTerminate(display); + assert(eglGetError() == EGL_SUCCESS); + assert(ret == EGL_TRUE); + +#ifdef REPORT_RESULT + REPORT_RESULT(); +#endif +} diff --git a/tests/test_other.py b/tests/test_other.py index 86e0eadf..11b2dcb3 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -169,7 +169,7 @@ Options that are modified or new in %s include: if keep_debug: assert ('(label)' in generated or '(label | 0)' in generated) == (opt_level <= 0), 'relooping should be in opt >= 1' assert ('assert(STACKTOP < STACK_MAX' in generated) == (opt_level == 0), 'assertions should be in opt == 0' - assert 'var $i;' in generated or 'var $i_0' in generated or 'var $storemerge3;' in generated or 'var $storemerge4;' in generated or '$i_04' in generated or '$i_05' in generated or 'var $original = 0' in generated, 'micro opts should always be on' + assert '$i' in generated or '$storemerge' in generated or '$original' in generated, 'micro opts should always be on' if opt_level >= 2 and '-g' in params: assert re.search('HEAP8\[\$?\w+ ?\+ ?\(+\$?\w+ ?', generated) or re.search('HEAP8\[HEAP32\[', generated), 'eliminator should create compound expressions, and fewer one-time vars' # also in -O1, but easier to test in -O2 assert ('_puts(' in generated) == (opt_level >= 1), 'with opt >= 1, llvm opts are run and they should optimize printf to puts' @@ -819,8 +819,12 @@ f.close() }), ]: Building.COMPILER_TEST_OPTS = test_opts + if WINDOWS: + zlib_library = self.get_library('zlib', os.path.join('libz.a'), configure=['emconfigure.bat'], configure_args=['cmake', '.', '-DBUILD_SHARED_LIBS=OFF'], make=['mingw32-make'], make_args=[]) + else: + zlib_library = self.get_library('zlib', os.path.join('libz.a'), make_args=['libz.a']) test('zlib', path_from_root('tests', 'zlib', 'example.c'), - self.get_library('zlib', os.path.join('libz.a'), make_args=['libz.a']), + zlib_library, open(path_from_root('tests', 'zlib', 'ref.txt'), 'r').read(), expected_ranges, args=['-I' + path_from_root('tests', 'zlib')], suffix='c') @@ -1440,10 +1444,12 @@ f.close() extern "C" { void something(); + void elsey(); } int main() { something(); + elsey(); return 0; } ''') @@ -1451,26 +1457,24 @@ f.close() def clear(): try_delete('a.out.js') for args in [[], ['-O2']]: - clear() - print 'warn', args - output = Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'main.cpp'), '-s', 'WARN_ON_UNDEFINED_SYMBOLS=1'] + args, stderr=PIPE).communicate() - self.assertContained('unresolved symbol: something', output[1]) - - clear() - output = Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'main.cpp')] + args, stderr=PIPE).communicate() - self.assertNotContained('unresolved symbol: something\n', output[1]) - - for args in [[], ['-O2']]: - clear() - print 'error', args - output = Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'main.cpp'), '-s', 'ERROR_ON_UNDEFINED_SYMBOLS=1'] + args, stderr=PIPE).communicate() - self.assertContained('unresolved symbol: something', output[1]) - assert not os.path.exists('a.out.js') - - clear() - output = Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'main.cpp')] + args, stderr=PIPE).communicate() - self.assertNotContained('unresolved symbol: something\n', output[1]) - assert os.path.exists('a.out.js') + for action in ['WARN', 'ERROR', None]: + for value in ([0, 1] if action else [0]): + clear() + print 'warn', args, action, value + extra = ['-s', action + '_ON_UNDEFINED_SYMBOLS=%d' % value] if action else [] + output = Popen([PYTHON, EMCC, os.path.join(self.get_dir(), 'main.cpp')] + extra + args, stderr=PIPE).communicate() + if action == None or (action == 'WARN' and value): + self.assertContained('unresolved symbol: something', output[1]) + self.assertContained('unresolved symbol: elsey', output[1]) + assert os.path.exists('a.out.js') + elif action == 'ERROR' and value: + self.assertContained('unresolved symbol: something', output[1]) + self.assertContained('unresolved symbol: elsey', output[1]) + self.assertNotContained('warning', output[1]) + assert not os.path.exists('a.out.js') + elif action == 'WARN' and not value: + self.assertNotContained('unresolved symbol', output[1]) + assert os.path.exists('a.out.js') def test_toobig(self): # very large [N x i8], we should not oom in the compiler @@ -1909,7 +1913,8 @@ done. out, err = Popen([PYTHON, EMCC, path_from_root('tests', 'hello_world.c'), '-E'], stdout=PIPE).communicate() assert not os.path.exists('a.out.js') - assert '''tests/hello_world.c"''' in out + assert '''#line 1 ''' in out + assert '''hello_world.c"''' in out assert '''printf("hello, world!''' in out def test_demangle(self): @@ -1927,6 +1932,7 @@ done. EM_ASM(Module.print(demangle('_main'))); EM_ASM(Module.print(demangle('__Z2f2v'))); EM_ASM(Module.print(demangle('__Z12abcdabcdabcdi'))); + EM_ASM(Module.print(demangle('__ZL12abcdabcdabcdi'))); EM_ASM(Module.print(demangle('__Z4testcsifdPvPiPc'))); EM_ASM(Module.print(demangle('__ZN4test5moarrEcslfdPvPiPc'))); EM_ASM(Module.print(demangle('__ZN4Waka1f12a234123412345pointEv'))); @@ -1937,6 +1943,7 @@ done. EM_ASM(Module.print(demangle('__Z9parsewordRPKciRi'))); EM_ASM(Module.print(demangle('__Z5multiwahtjmxyz'))); EM_ASM(Module.print(demangle('__Z1aA32_iPA5_c'))); + EM_ASM(Module.print(demangle('__ZN21FWakaGLXFleeflsMarfooC2EjjjPKvbjj'))); one(17); return 0; } @@ -1944,9 +1951,11 @@ done. Popen([PYTHON, EMCC, 'src.cpp', '-s', 'LINKABLE=1']).communicate() output = run_js('a.out.js') - self.assertContained('''main + self.assertContained('''operator new() +_main f2() abcdabcdabcd(int) +abcdabcdabcd(int) test(char, short, int, float, double, void*, int*, char*) test::moarr(char, short, long, float, double, void*, int*, char*) Waka::f::a23412341234::point() @@ -1957,6 +1966,7 @@ __cxxabiv1::__si_class_type_info::search_below_dst(__cxxabiv1::__dynamic_cast_in parseword(char*&, int, int&) multi(wchar_t, signed char, unsigned char, unsigned short, unsigned int, unsigned long, long long, unsigned long long, ...) a(int [32], char [5]*) +FWakaGLXFleeflsMarfoo::FWakaGLXFleeflsMarfoo(unsigned int, unsigned int, unsigned int, void*, bool, unsigned int, unsigned int) ''', output) # test for multiple functions in one stack trace assert 'one(int)' in output @@ -2010,6 +2020,49 @@ a(int [32], char [5]*) try_delete(path_from_root('tests', 'Module-exports', 'test.js')) try_delete(path_from_root('tests', 'Module-exports', 'test.js.map')) + def test_fs_stream_proto(self): + open('src.cpp', 'wb').write(r''' +#include <stdio.h> +#include <fcntl.h> +#include <unistd.h> +#include <sys/stat.h> +#include <errno.h> +#include <string.h> + +int main() +{ + int file_size = 0; + int h = open("src.cpp", O_RDONLY, 0666); + if (0 != h) + { + FILE* file = fdopen(h, "rb"); + if (0 != file) + { + fseek(file, 0, SEEK_END); + file_size = ftell(file); + fseek(file, 0, SEEK_SET); + } + else + { + printf("fdopen() failed: %s\n", strerror(errno)); + return 10; + } + close(h); + printf("File size: %d\n", file_size); + } + else + { + printf("open() failed: %s\n", strerror(errno)); + return 10; + } + return 0; +} + ''') + Popen([PYTHON, EMCC, 'src.cpp', '--embed-file', 'src.cpp']).communicate() + for engine in JS_ENGINES: + out = run_js('a.out.js', engine=engine, stderr=PIPE, full_output=True) + self.assertContained('File size: 722', out) + def test_simd(self): self.clear() Popen([PYTHON, EMCC, path_from_root('tests', 'linpack.c'), '-O2', '-DSP', '--llvm-opts', '''['-O3', '-vectorize', '-vectorize-loops', '-bb-vectorize-vector-bits=128', '-force-vector-width=4']''']).communicate() diff --git a/tests/test_sockets.py b/tests/test_sockets.py index d2bc46a2..e1caa150 100644 --- a/tests/test_sockets.py +++ b/tests/test_sockets.py @@ -400,3 +400,29 @@ class sockets(BrowserCore): expected = '1' self.run_browser(host_outfile, '.', ['/report_result?' + e for e in expected]) + def test_nodejs_sockets_echo(self): + # This test checks that sockets work when the client code is run in Node.js + # Run with ./runner.py sockets.test_nodejs_sockets_echo + if not NODE_JS in JS_ENGINES: + return self.skip('node is not present') + + sockets_include = '-I'+path_from_root('tests', 'sockets') + + # Websockify-proxied servers can't run dgram tests + harnesses = [ + # Websockify doesn't seem to like ws.WebSocket clients TODO check if this is a ws issue or Websockify issue + #(WebsockifyServerHarness(os.path.join('sockets', 'test_sockets_echo_server.c'), [sockets_include], 49160), 0), + (CompiledServerHarness(os.path.join('sockets', 'test_sockets_echo_server.c'), [sockets_include, '-DTEST_DGRAM=0'], 49161), 0), + (CompiledServerHarness(os.path.join('sockets', 'test_sockets_echo_server.c'), [sockets_include, '-DTEST_DGRAM=1'], 49162), 1) + ] + + for harness, datagram in harnesses: + with harness: + Popen([PYTHON, EMCC, path_from_root('tests', 'sockets', 'test_sockets_echo_client.c'), '-o', path_from_root('tests', 'sockets', 'client.js'), '-DSOCKK=%d' % harness.listen_port, '-DREPORT_RESULT=int dummy'], stdout=PIPE, stderr=PIPE).communicate() + + self.assertContained('do_msg_read: read 14 bytes', run_js(path_from_root('tests', 'sockets', 'client.js'), engine=NODE_JS)) + + # Tidy up files that might have been created by this test. + try_delete(path_from_root('tests', 'sockets', 'client.js')) + try_delete(path_from_root('tests', 'sockets', 'client.js.map')) + diff --git a/tests/zlib/CMakeLists.txt b/tests/zlib/CMakeLists.txt new file mode 100644 index 00000000..01a19fb5 --- /dev/null +++ b/tests/zlib/CMakeLists.txt @@ -0,0 +1,190 @@ +cmake_minimum_required(VERSION 2.4.4) +set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON) + +project(zlib C) + +if(NOT DEFINED BUILD_SHARED_LIBS) + option(BUILD_SHARED_LIBS "Build a shared library form of zlib" ON) +endif() + +include(CheckTypeSize) +include(CheckFunctionExists) +include(CheckIncludeFile) +include(CheckCSourceCompiles) +enable_testing() + +check_include_file(sys/types.h HAVE_SYS_TYPES_H) +check_include_file(stdint.h HAVE_STDINT_H) +check_include_file(stddef.h HAVE_STDDEF_H) + +# +# Check to see if we have large file support +# +set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1) +# We add these other definitions here because CheckTypeSize.cmake +# in CMake 2.4.x does not automatically do so and we want +# compatibility with CMake 2.4.x. +if(HAVE_SYS_TYPES_H) + list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H) +endif() +if(HAVE_STDINT_H) + list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H) +endif() +if(HAVE_STDDEF_H) + list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H) +endif() +check_type_size(off64_t OFF64_T) +if(HAVE_OFF64_T) + add_definitions(-D_LARGEFILE64_SOURCE=1) +endif() +set(CMAKE_REQUIRED_DEFINITIONS) # clear variable + +# +# Check for fseeko +# +check_function_exists(fseeko HAVE_FSEEKO) +if(NOT HAVE_FSEEKO) + add_definitions(-DNO_FSEEKO) +endif() + +# +# Check for unistd.h +# +check_include_file(unistd.h Z_HAVE_UNISTD_H) + +if(MSVC) + set(CMAKE_DEBUG_POSTFIX "d") + add_definitions(-D_CRT_SECURE_NO_DEPRECATE) + add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE) +endif() + +if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR) + # If we're doing an out of source build and the user has a zconf.h + # in their source tree... + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h) + message(FATAL_ERROR + "You must remove ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h " + "from the source tree. This file is included with zlib " + "but CMake generates this file for you automatically " + "in the build directory.") + endif() +endif() + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein + ${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY) +include_directories(${CMAKE_CURRENT_BINARY_DIR}) + + +#============================================================================ +# zlib +#============================================================================ + +set(ZLIB_PUBLIC_HDRS + ${CMAKE_CURRENT_BINARY_DIR}/zconf.h + zlib.h +) +set(ZLIB_PRIVATE_HDRS + crc32.h + deflate.h + gzguts.h + inffast.h + inffixed.h + inflate.h + inftrees.h + trees.h + zutil.h +) +set(ZLIB_SRCS + adler32.c + compress.c + crc32.c + deflate.c + gzclose.c + gzlib.c + gzread.c + gzwrite.c + inflate.c + infback.c + inftrees.c + inffast.c + trees.c + uncompr.c + zutil.c +# win32/zlib1.rc XXX Emscripten remove the Windows resource file from build, not needed and not included in source tree. +) + +# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION +file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents) +string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([0-9A-Za-z.]+)\".*" + "\\1" ZLIB_FULL_VERSION ${_zlib_h_contents}) + +if(MINGW) + # This gets us DLL resource information when compiling on MinGW. + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj + COMMAND windres.exe + -D GCC_WINDRES + -I ${CMAKE_CURRENT_SOURCE_DIR} + -I ${CMAKE_CURRENT_BINARY_DIR} + -o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj + -i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc) + set(ZLIB_SRCS ${ZLIB_SRCS} ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) +endif(MINGW) + +add_library(zlib ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) +set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) + +set_target_properties(zlib PROPERTIES SOVERSION 1) + +if(NOT CYGWIN) + # This property causes shared libraries on Linux to have the full version + # encoded into their final filename. We disable this on Cygwin because + # it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll + # seems to be the default. + # + # This has no effect with MSVC, on that platform the version info for + # the DLL comes from the resource file win32/zlib1.rc + set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION}) +endif() + +if(UNIX) + # On unix-like platforms the library is almost always called libz + set_target_properties(zlib PROPERTIES OUTPUT_NAME z) +elseif(BUILD_SHARED_LIBS AND WIN32) + # Creates zlib1.dll when building shared library version + set_target_properties(zlib PROPERTIES SUFFIX "1.dll") +endif() + +if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) + install(TARGETS zlib + RUNTIME DESTINATION bin + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib ) +endif() +if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL ) + install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION include) +endif() +if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) + install(FILES zlib.3 DESTINATION share/man/man3) +endif() + +#============================================================================ +# Example binaries +#============================================================================ + +add_executable(example example.c) +target_link_libraries(example zlib) +add_test(example example) + +add_executable(minigzip minigzip.c) +target_link_libraries(minigzip zlib) + +if(HAVE_OFF64_T) + add_executable(example64 example.c) + target_link_libraries(example64 zlib) + set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") + add_test(example64 example64) + + add_executable(minigzip64 minigzip.c) + target_link_libraries(minigzip64 zlib) + set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64") +endif() diff --git a/tests/zlib/zconf.h b/tests/zlib/zconf.h.cmakein index b2343874..a2f71b1f 100644 --- a/tests/zlib/zconf.h +++ b/tests/zlib/zconf.h.cmakein @@ -7,6 +7,8 @@ #ifndef ZCONF_H #define ZCONF_H +#cmakedefine Z_PREFIX +#cmakedefine Z_HAVE_UNISTD_H /* * If you *really* need a unique prefix for all types and library functions, @@ -356,7 +358,7 @@ typedef uLong FAR uLongf; typedef Byte *voidp; #endif -#if 1 /* was set to #if 1 by ./configure */ +#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */ # define Z_HAVE_UNISTD_H #endif diff --git a/third_party/lzma.js/doit.sh b/third_party/lzma.js/doit.sh index 1f530651..6046022c 100755 --- a/third_party/lzma.js/doit.sh +++ b/third_party/lzma.js/doit.sh @@ -5,7 +5,14 @@ export CXX=`../../../em-config LLVM_ROOT`/clang++ echo "native" make clean DECODER_ONLY=0 make lzip -j 4 # native build -mv lzip ../lzma-native +case `uname` in + *_NT*) + mv lzip.exe ../lzma-native.exe + ;; + *) + mv lzip ../lzma-native + ;; +esac exit # just build natively, that's it @@ -18,7 +25,7 @@ echo "bitcode decoder only" make clean DECODER_ONLY=1 ../../../emmake make lzip -j 4 mv lzip lzip-decoder.bc - + cd .. echo "javascript full" diff --git a/tools/eliminator/asm-eliminator-test-output.js b/tools/eliminator/asm-eliminator-test-output.js index dda82047..434fbaf9 100644 --- a/tools/eliminator/asm-eliminator-test-output.js +++ b/tools/eliminator/asm-eliminator-test-output.js @@ -291,4 +291,11 @@ function watIf() { if ($cmp38) {} else {} } } +function select2($foundBase_0_off0) { + $foundBase_0_off0 = $foundBase_0_off0 | 0; + var $call24 = 0; + $call24 = MUST_RUN() | 0; + STACKTOP = sp; + return ($foundBase_0_off0 ? 0 : $call24) | 0; +} diff --git a/tools/eliminator/asm-eliminator-test.js b/tools/eliminator/asm-eliminator-test.js index 6f426150..7ec277d5 100644 --- a/tools/eliminator/asm-eliminator-test.js +++ b/tools/eliminator/asm-eliminator-test.js @@ -362,5 +362,13 @@ function watIf() { } } } -// EMSCRIPTEN_GENERATED_FUNCTIONS: ["asm", "__Z11printResultPiS_j", "_segment_holding", "__ZN5identC2EiPKcPci", "_vec2Length", "exc", "label", "confuusion", "tempDouble", "_org_apache_harmony_luni_util_NumberConverter_freeFormat__", "__ZN23b2EdgeAndPolygonContact8EvaluateEP10b2ManifoldRK11b2TransformS4_", "_java_nio_charset_Charset_forNameInternal___java_lang_String", "looop2", "looop3", "looop4", "looop5", "looop6", "looop7", "looop8", "multiloop", "multiloop2", "tempDouble2", "watIf"] +function select2($foundBase_0_off0) { + $foundBase_0_off0 = $foundBase_0_off0 | 0; + var $call24 = 0, $retval_0 = 0; + $call24 = MUST_RUN() | 0; + $retval_0 = $foundBase_0_off0 ? 0 : $call24; + STACKTOP = sp; + return $retval_0 | 0; +} +// EMSCRIPTEN_GENERATED_FUNCTIONS: ["asm", "__Z11printResultPiS_j", "_segment_holding", "__ZN5identC2EiPKcPci", "_vec2Length", "exc", "label", "confuusion", "tempDouble", "_org_apache_harmony_luni_util_NumberConverter_freeFormat__", "__ZN23b2EdgeAndPolygonContact8EvaluateEP10b2ManifoldRK11b2TransformS4_", "_java_nio_charset_Charset_forNameInternal___java_lang_String", "looop2", "looop3", "looop4", "looop5", "looop6", "looop7", "looop8", "multiloop", "multiloop2", "tempDouble2", "watIf", "select2"] diff --git a/tools/eliminator/eliminator-test-output.js b/tools/eliminator/eliminator-test-output.js index 1a6506ed..0171e99b 100644 --- a/tools/eliminator/eliminator-test-output.js +++ b/tools/eliminator/eliminator-test-output.js @@ -6119,4 +6119,7 @@ function intoCond() { HEAP32[$115 >> 2] = $NumWords; } } +function math(a, b, c, d) { + print(Math_imul(d) + (Math_fround(c) + (a + Math_abs(b)))); +} diff --git a/tools/eliminator/eliminator-test.js b/tools/eliminator/eliminator-test.js index ffad69ea..ef17b388 100644 --- a/tools/eliminator/eliminator-test.js +++ b/tools/eliminator/eliminator-test.js @@ -8852,5 +8852,13 @@ function intoCond() { HEAP32[$504 >> 2] = $503; } } -// EMSCRIPTEN_GENERATED_FUNCTIONS: ["a", "b", "c", "f", "g", "h", "py", "r", "t", "f2", "f3", "llvm3_1", "_inflate", "_malloc", "_mallocNoU", "asm", "phi", "intoCond"] +function math(a, b, c, d) { + var x, y, z, w; + x = a; + y = Math_abs(b); + z = Math_fround(c); + w = Math_imul(d); + print(x + y + z + w); +} +// EMSCRIPTEN_GENERATED_FUNCTIONS: ["a", "b", "c", "f", "g", "h", "py", "r", "t", "f2", "f3", "llvm3_1", "_inflate", "_malloc", "_mallocNoU", "asm", "phi", "intoCond", "math"] diff --git a/tools/file_packager.py b/tools/file_packager.py index 1d0ec447..3ba5b23f 100644 --- a/tools/file_packager.py +++ b/tools/file_packager.py @@ -11,7 +11,7 @@ data downloads. Usage: - file_packager.py TARGET [--preload A [B..]] [--embed C [D..]] [--compress COMPRESSION_DATA] [--crunch[=X]] [--js-output=OUTPUT.js] [--no-force] + file_packager.py TARGET [--preload A [B..]] [--embed C [D..]] [--compress COMPRESSION_DATA] [--crunch[=X]] [--js-output=OUTPUT.js] [--no-force] [--use-preload-cache] [--no-heap-copy] --crunch=X Will compress dxt files to crn with quality level X. The crunch commandline tool must be present and CRUNCH should be defined in ~/.emscripten that points to it. JS crunch decompressing code will @@ -27,6 +27,10 @@ Usage: --use-preload-cache Stores package in IndexedDB so that subsequent loads don't need to do XHR. Checks package version. + --no-heap-copy If specified, the preloaded filesystem is not copied inside the Emscripten HEAP, but kept in a separate typed array outside it. + The default, if this is not specified, is to embed the VFS inside the HEAP, so that mmap()ing files in it is a no-op. + Passing this flag optimizes for fread() usage, omitting it optimizes for mmap() usage. + Notes: * The file packager generates unix-style file paths. So if you are on windows and a file is accessed at @@ -43,7 +47,7 @@ from shared import Compression, execute, suffix, unsuffixed from subprocess import Popen, PIPE, STDOUT if len(sys.argv) == 1: - print '''Usage: file_packager.py TARGET [--preload A...] [--embed B...] [--compress COMPRESSION_DATA] [--crunch[=X]] [--js-output=OUTPUT.js] [--no-force] [--use-preload-cache] + print '''Usage: file_packager.py TARGET [--preload A...] [--embed B...] [--compress COMPRESSION_DATA] [--crunch[=X]] [--js-output=OUTPUT.js] [--no-force] [--use-preload-cache] [--no-heap-copy] See the source for more details.''' sys.exit(0) @@ -70,7 +74,12 @@ crunch = 0 plugins = [] jsoutput = None force = True +# If set to True, IndexedDB (IDBFS in library_idbfs.js) is used to locally cache VFS XHR so that subsequent +# page loads can read the data from the offline cache instead. use_preload_cache = False +# If set to True, the blob received from XHR is moved to the Emscripten HEAP, optimizing for mmap() performance. +# If set to False, the XHR blob is kept intact, and fread()s etc. are performed directly to that data. This optimizes for minimal memory usage and fread() performance. +no_heap_copy = True for arg in sys.argv[1:]: if arg == '--preload': @@ -91,6 +100,8 @@ for arg in sys.argv[1:]: force = False elif arg == '--use-preload-cache': use_preload_cache = True + elif arg == '--no-heap-copy': + no_heap_copy = False elif arg.startswith('--js-output'): jsoutput = arg.split('=')[1] if '=' in arg else None elif arg.startswith('--crunch'): @@ -414,12 +425,18 @@ for file_ in data_files: if has_preloaded: # Get the big archive and split it up - use_data = ''' + if no_heap_copy: + use_data = ''' // copy the entire loaded file into a spot in the heap. Files will refer to slices in that. They cannot be freed though. var ptr = Module['_malloc'](byteArray.length); Module['HEAPU8'].set(byteArray, ptr); DataRequest.prototype.byteArray = Module['HEAPU8'].subarray(ptr, ptr+byteArray.length); ''' + else: + use_data = ''' + // Reuse the bytearray from the XHR as the source for file reads. + DataRequest.prototype.byteArray = byteArray; +''' for file_ in data_files: if file_['mode'] == 'preload': use_data += ' DataRequest.prototype.requests["%s"].onload();\n' % (file_['dstpath']) diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js index 022bdf47..57ce0071 100644 --- a/tools/js-optimizer.js +++ b/tools/js-optimizer.js @@ -618,6 +618,7 @@ function simplifyExpressions(ast) { if (asm) { if (hasTempDoublePtr) { + var asmData = normalizeAsm(ast); traverse(ast, function(node, type) { if (type === 'assign') { if (node[1] === true && node[2][0] === 'sub' && node[2][1][0] === 'name' && node[2][1][1] === 'HEAP32') { @@ -642,7 +643,7 @@ function simplifyExpressions(ast) { node[2][0] !== 'seq') { // avoid (x, y, z) which can be used for tempDoublePtr on doubles for alignment fixes if (node[1][2][1][1] === 'HEAP32') { node[1][3][1][1] = 'HEAPF32'; - return ['unary-prefix', '+', node[1][3]]; + return makeAsmCoercion(node[1][3], detectAsmCoercion(node[2])); } else { node[1][3][1][1] = 'HEAP32'; return ['binary', '|', node[1][3], ['num', 0]]; @@ -686,7 +687,6 @@ function simplifyExpressions(ast) { } } }); - var asmData = normalizeAsm(ast); for (var v in bitcastVars) { var info = bitcastVars[v]; // good variables define only one type, use only one type, have definitions and uses, and define as a different type than they use @@ -1142,13 +1142,28 @@ function simplifyNotComps(ast) { simplifyNotCompsPass = false; } -var NO_SIDE_EFFECTS = set('num', 'name'); +function callHasSideEffects(node) { // checks if the call itself (not the args) has side effects (or is not statically known) + return !(node[1][0] === 'name' && /^Math_/.test(node[1][1])); +} function hasSideEffects(node) { // this is 99% incomplete! - if (node[0] in NO_SIDE_EFFECTS) return false; - if (node[0] === 'unary-prefix') return hasSideEffects(node[2]); - if (node[0] === 'binary') return hasSideEffects(node[2]) || hasSideEffects(node[3]); - return true; + switch (node[0]) { + case 'num': case 'name': case 'string': return false; + case 'unary-prefix': return hasSideEffects(node[2]); + case 'binary': return hasSideEffects(node[2]) || hasSideEffects(node[3]); + case 'sub': return hasSideEffects(node[1]) || hasSideEffects(node[2]); + case 'call': { + if (callHasSideEffects(node)) return true; + // This is a statically known call, with no side effects. only args can side effect us + var args = node[2]; + var num = args.length; + for (var i = 0; i < num; i++) { + if (hasSideEffects(args[i])) return true; + } + return false; + } + default: return true; + } } // Clear out empty ifs and blocks, and redundant blocks/stats and so forth @@ -1515,21 +1530,33 @@ function unVarify(vars, ret) { // transform var x=1, y=2 etc. into (x=1, y=2), i // annotations, plus explicit metadata) and denormalize (vice versa) var ASM_INT = 0; var ASM_DOUBLE = 1; +var ASM_FLOAT = 2; function detectAsmCoercion(node, asmInfo) { // for params, +x vs x|0, for vars, 0.0 vs 0 if (node[0] === 'num' && node[1].toString().indexOf('.') >= 0) return ASM_DOUBLE; if (node[0] === 'unary-prefix') return ASM_DOUBLE; + if (node[0] === 'call' && node[1][0] === 'name' && node[1][1] === 'Math_fround') return ASM_FLOAT; if (asmInfo && node[0] == 'name') return getAsmType(node[1], asmInfo); return ASM_INT; } function makeAsmCoercion(node, type) { - return type === ASM_INT ? ['binary', '|', node, ['num', 0]] : ['unary-prefix', '+', node]; + switch (type) { + case ASM_INT: return ['binary', '|', node, ['num', 0]]; + case ASM_DOUBLE: return ['unary-prefix', '+', node]; + case ASM_FLOAT: return ['call', ['name', 'Math_fround'], [node]]; + default: throw 'wha? ' + JSON.stringify([node, type]) + new Error().stack; + } } function makeAsmVarDef(v, type) { - return [v, type === ASM_INT ? ['num', 0] : ['unary-prefix', '+', ['num', 0]]]; + switch (type) { + case ASM_INT: return [v, ['num', 0]]; + case ASM_DOUBLE: return [v, ['unary-prefix', '+', ['num', 0]]]; + case ASM_FLOAT: return [v, ['call', ['name', 'Math_fround'], [['num', 0]]]]; + default: throw 'wha?'; + } } function getAsmType(name, asmInfo) { @@ -1568,7 +1595,8 @@ function normalizeAsm(func) { var name = v[0]; var value = v[1]; if (!(name in data.vars)) { - assert(value[0] === 'num' || (value[0] === 'unary-prefix' && value[2][0] === 'num')); // must be valid coercion no-op + assert(value[0] === 'num' || (value[0] === 'unary-prefix' && value[2][0] === 'num') // must be valid coercion no-op + || (value[0] === 'call' && value[1][0] === 'name' && value[1][1] === 'Math_fround')); data.vars[name] = detectAsmCoercion(value); v.length = 1; // make an un-assigning var } else { @@ -1917,7 +1945,7 @@ function registerize(ast) { // we just use a fresh register to make sure we avoid this, but it could be // optimized to check for safe registers (free, and not used in this loop level). var varRegs = {}; // maps variables to the register they will use all their life - var freeRegsClasses = asm ? [[], []] : []; // two classes for asm, one otherwise + var freeRegsClasses = asm ? [[], [], []] : []; // two classes for asm, one otherwise XXX - hardcoded length var nextReg = 1; var fullNames = {}; var loopRegs = {}; // for each loop nesting level, the list of bound variables @@ -2031,6 +2059,33 @@ function registerize(ast) { } } denormalizeAsm(fun, finalAsmData); + if (extraInfo && extraInfo.globals) { + // minify in asm var definitions, that denormalizeAsm just generated + function minify(value) { + if (value && value[0] === 'call' && value[1][0] === 'name') { + var name = value[1][1]; + var minified = extraInfo.globals[name]; + if (minified) { + value[1][1] = minified; + } + } + } + var stats = fun[3]; + for (var i = 0; i < stats.length; i++) { + var line = stats[i]; + if (i >= fun[2].length && line[0] !== 'var') break; // when we pass the arg and var coercions, break + if (line[0] === 'stat') { + assert(line[1][0] === 'assign'); + minify(line[1][3]); + } else { + assert(line[0] === 'var'); + var pairs = line[1]; + for (var j = 0; j < pairs.length; j++) { + minify(pairs[j][1]); + } + } + } + } } }); } @@ -2068,7 +2123,6 @@ function registerize(ast) { // can happen in ALLOW_MEMORY_GROWTH mode var ELIMINATION_SAFE_NODES = set('var', 'assign', 'call', 'if', 'toplevel', 'do', 'return', 'label', 'switch'); // do is checked carefully, however -var NODES_WITHOUT_ELIMINATION_SIDE_EFFECTS = set('name', 'num', 'string', 'binary', 'sub', 'unary-prefix'); var IGNORABLE_ELIMINATOR_SCAN_NODES = set('num', 'toplevel', 'string', 'break', 'continue', 'dot'); // dot can only be STRING_TABLE.* var ABORTING_ELIMINATOR_SCAN_NODES = set('new', 'object', 'function', 'defun', 'for', 'while', 'array', 'throw'); // we could handle some of these, TODO, but nontrivial (e.g. for while, the condition is hit multiple times after the body) @@ -2160,7 +2214,7 @@ function eliminate(ast, memSafe) { if (definitions[name] === 1 && uses[name] === 1) { potentials[name] = 1; } else if (uses[name] === 0 && (!definitions[name] || definitions[name] <= 1)) { // no uses, no def or 1 def (cannot operate on phis, and the llvm optimizer will remove unneeded phis anyhow) (no definition means it is a function parameter, or a local with just |var x;| but no defining assignment) - var hasSideEffects = false; + var sideEffects = false; var value = values[name]; if (value) { // TODO: merge with other side effect code @@ -2170,15 +2224,10 @@ function eliminate(ast, memSafe) { if (!(value[0] === 'seq' && value[1][0] === 'assign' && value[1][2][0] === 'sub' && value[1][2][2][0] === 'binary' && value[1][2][2][1] === '>>' && value[1][2][2][2][0] === 'name' && value[1][2][2][2][1] === 'tempDoublePtr')) { // If not that, then traverse and scan normally. - traverse(value, function(node, type) { - if (!(type in NODES_WITHOUT_ELIMINATION_SIDE_EFFECTS)) { - hasSideEffects = true; // cannot remove this unused variable, constructing it has side effects - return true; - } - }); + sideEffects = hasSideEffects(value); } } - if (!hasSideEffects) { + if (!sideEffects) { varsToRemove[name] = !definitions[name] ? 2 : 1; // remove it normally sideEffectFree[name] = true; // Each time we remove a variable with 0 uses, if its value has no @@ -2437,14 +2486,16 @@ function eliminate(ast, memSafe) { for (var i = 0; i < args.length; i++) { traverseInOrder(args[i]); } - // these two invalidations will also invalidate calls - if (!globalsInvalidated) { - invalidateGlobals(); - globalsInvalidated = true; - } - if (!memoryInvalidated) { - invalidateMemory(); - memoryInvalidated = true; + if (callHasSideEffects(node)) { + // these two invalidations will also invalidate calls + if (!globalsInvalidated) { + invalidateGlobals(); + globalsInvalidated = true; + } + if (!memoryInvalidated) { + invalidateMemory(); + memoryInvalidated = true; + } } } else if (type === 'if') { if (allowTracking) { @@ -2485,6 +2536,10 @@ function eliminate(ast, memSafe) { } else if (type === 'return') { if (node[1]) traverseInOrder(node[1]); } else if (type === 'conditional') { + if (!callsInvalidated) { // invalidate calls, since we cannot eliminate them into a branch of an LLVM select/JS conditional that does not execute + invalidateCalls(); + callsInvalidated = true; + } traverseInOrder(node[1]); traverseInOrder(node[2]); traverseInOrder(node[3]); @@ -3169,7 +3224,7 @@ function outline(ast) { var writes = {}; var namings = {}; - var hasReturn = false, hasReturnInt = false, hasReturnDouble = false, hasBreak = false, hasContinue = false; + var hasReturn = false, hasReturnType = {}, hasBreak = false, hasContinue = false; var breaks = {}; // set of labels we break or continue var continues = {}; // to (name -> id, just like labels) var breakCapturers = 0; @@ -3189,10 +3244,8 @@ function outline(ast) { } else if (type == 'return') { if (!node[1]) { hasReturn = true; - } else if (detectAsmCoercion(node[1]) == ASM_INT) { - hasReturnInt = true; } else { - hasReturnDouble = true; + hasReturnType[detectAsmCoercion(node[1])] = true; } } else if (type == 'break') { var label = node[1] || 0; @@ -3222,7 +3275,6 @@ function outline(ast) { continueCapturers--; } }); - assert(hasReturn + hasReturnInt + hasReturnDouble <= 1); var reads = {}; for (var v in namings) { @@ -3230,7 +3282,7 @@ function outline(ast) { if (actualReads > 0) reads[v] = actualReads; } - return { writes: writes, reads: reads, hasReturn: hasReturn, hasReturnInt: hasReturnInt, hasReturnDouble: hasReturnDouble, hasBreak: hasBreak, hasContinue: hasContinue, breaks: breaks, continues: continues, labels: labels }; + return { writes: writes, reads: reads, hasReturn: hasReturn, hasReturnType: hasReturnType, hasBreak: hasBreak, hasContinue: hasContinue, breaks: breaks, continues: continues, labels: labels }; } function makeAssign(dst, src) { @@ -3251,7 +3303,10 @@ function outline(ast) { return ['switch', value, cases]; } - var CONTROL_BREAK = 1, CONTROL_BREAK_LABEL = 2, CONTROL_CONTINUE = 3, CONTROL_CONTINUE_LABEL = 4, CONTROL_RETURN_VOID = 5, CONTROL_RETURN_INT = 6, CONTROL_RETURN_DOUBLE = 7; + var CONTROL_BREAK = 1, CONTROL_BREAK_LABEL = 2, CONTROL_CONTINUE = 3, CONTROL_CONTINUE_LABEL = 4, CONTROL_RETURN_VOID = 5, CONTROL_RETURN_INT = 6, CONTROL_RETURN_DOUBLE = 7, CONTROL_RETURN_FLOAT = 8; + function controlFromAsmType(asmType) { + return CONTROL_RETURN_INT + (asmType | 0); // assumes ASM_INT starts at 0, and order of these two is identical! + } var sizeToOutline = null; // customized per function and as we make progress function calculateThreshold(func, asmData) { @@ -3310,7 +3365,7 @@ function outline(ast) { }); // Generate new function - if (codeInfo.hasReturn || codeInfo.hasReturnInt || codeInfo.hasReturnDouble || codeInfo.hasBreak || codeInfo.hasContinue) { + if (codeInfo.hasReturn || codeInfo.hasReturnType[ASM_INT] || codeInfo.hasReturnType[ASM_DOUBLE] || codeInfo.hasReturnType[ASM_FLOAT] || codeInfo.hasBreak || codeInfo.hasContinue) { // we need to capture all control flow using a top-level labeled one-time loop in the outlined function var breakCapturers = 0; var continueCapturers = 0; @@ -3335,7 +3390,7 @@ function outline(ast) { ret.push(['stat', makeAssign(makeStackAccess(ASM_INT, asmData.controlStackPos(outlineIndex)), ['num', CONTROL_RETURN_VOID])]); } else { var type = detectAsmCoercion(node[1], asmData); - ret.push(['stat', makeAssign(makeStackAccess(ASM_INT, asmData.controlStackPos(outlineIndex)), ['num', type == ASM_INT ? CONTROL_RETURN_INT : CONTROL_RETURN_DOUBLE])]); + ret.push(['stat', makeAssign(makeStackAccess(ASM_INT, asmData.controlStackPos(outlineIndex)), ['num', controlFromAsmType(type)])]); ret.push(['stat', makeAssign(makeStackAccess(type, asmData.controlDataStackPos(outlineIndex)), node[1])]); } ret.push(['stat', ['break', 'OL']]); @@ -3398,16 +3453,10 @@ function outline(ast) { [['stat', ['return']]] )); } - if (codeInfo.hasReturnInt) { + for (var returnType in codeInfo.hasReturnType) { reps.push(makeIf( - makeComparison(makeAsmCoercion(['name', 'tempValue'], ASM_INT), '==', ['num', CONTROL_RETURN_INT]), - [['stat', ['return', makeAsmCoercion(['name', 'tempInt'], ASM_INT)]]] - )); - } - if (codeInfo.hasReturnDouble) { - reps.push(makeIf( - makeComparison(makeAsmCoercion(['name', 'tempValue'], ASM_INT), '==', ['num', CONTROL_RETURN_DOUBLE]), - [['stat', ['return', makeAsmCoercion(['name', 'tempDouble'], ASM_DOUBLE)]]] + makeComparison(makeAsmCoercion(['name', 'tempValue'], ASM_INT), '==', ['num', controlFromAsmType(returnType)]), + [['stat', ['return', makeAsmCoercion(['name', 'tempInt'], returnType | 0)]]] )); } if (codeInfo.hasBreak) { @@ -3486,8 +3535,9 @@ function outline(ast) { var last = getStatements(func)[getStatements(func).length-1]; if (last[0] === 'stat') last = last[1]; if (last[0] !== 'return') { - if (allCodeInfo.hasReturnInt || allCodeInfo.hasReturnDouble) { - getStatements(func).push(['stat', ['return', makeAsmCoercion(['num', 0], allCodeInfo.hasReturnInt ? ASM_INT : ASM_DOUBLE)]]); + for (var returnType in codeInfo.hasReturnType) { + getStatements(func).push(['stat', ['return', makeAsmCoercion(['num', 0], returnType | 0)]]); + break; } } outliningParents[newIdent] = func[1]; diff --git a/tools/response_file.py b/tools/response_file.py index f19cf8af..7f916752 100644 --- a/tools/response_file.py +++ b/tools/response_file.py @@ -1,4 +1,5 @@ import tempfile, os, sys, shlex +import shared # Routes the given cmdline param list in args into a new response file and returns the filename to it. # The returned filename has a suffix '.rsp'. @@ -9,6 +10,11 @@ def create_response_file(args, directory): args = map(lambda p: p.replace('\\', '\\\\').replace('"', '\\"'), args) response_fd.write('"' + '" "'.join(args) + '"') response_fd.close() + + # Register the created .rsp file to be automatically cleaned up once this process finishes, so that + # caller does not have to remember to do it. + shared.configuration.get_temp_files().note(response_filename) + return response_filename # Reads a response file, and returns the list of cmdline params found in the file. diff --git a/tools/shared.py b/tools/shared.py index d38aef4c..e2c6e89f 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -3,7 +3,7 @@ from subprocess import Popen, PIPE, STDOUT from tempfile import mkstemp from distutils.spawn import find_executable import jsrun, cache, tempfiles -from response_file import create_response_file +import response_file import logging, platform def listify(x): @@ -41,8 +41,8 @@ class WindowsPopen: # emscripten.py supports reading args from a response file instead of cmdline. # Use .rsp to avoid cmdline length limitations on Windows. if len(args) >= 2 and args[1].endswith("emscripten.py"): - self.response_filename = create_response_file(args[2:], TEMP_DIR) - args = args[0:2] + ['@' + self.response_filename] + response_filename = response_file.create_response_file(args[2:], TEMP_DIR) + args = args[0:2] + ['@' + response_filename] try: # Call the process with fixed streams. @@ -78,13 +78,6 @@ class WindowsPopen: def kill(self): return self.process.kill() - def __del__(self): - try: - # Clean up the temporary response file that was used to spawn this process, so that we don't leave temp files around. - tempfiles.try_delete(self.response_filename) - except: - pass # Mute all exceptions in dtor, particularly if we didn't use a response file, self.response_filename doesn't exist. - __rootpath__ = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) def path_from_root(*pathelems): return os.path.join(__rootpath__, *pathelems) @@ -314,7 +307,7 @@ def find_temp_directory(): # we re-check sanity when the settings are changed) # We also re-check sanity and clear the cache when the version changes -EMSCRIPTEN_VERSION = '1.7.2' +EMSCRIPTEN_VERSION = '1.7.6' def generate_sanity(): return EMSCRIPTEN_VERSION + '|' + get_llvm_target() + '|' + LLVM_ROOT @@ -1214,7 +1207,13 @@ class Building: # Run Emscripten Settings.RELOOPER = Cache.get_path('relooper.js') settings = Settings.serialize() - compiler_output = jsrun.timeout_run(Popen([PYTHON, EMSCRIPTEN, filename + ('.o.ll' if append_ext else ''), '-o', filename + '.o.js'] + settings + extra_args, stdout=PIPE), None, 'Compiling') + args = settings + extra_args + if WINDOWS: + args = ['@' + response_file.create_response_file(args, TEMP_DIR)] + cmdline = [PYTHON, EMSCRIPTEN, filename + ('.o.ll' if append_ext else ''), '-o', filename + '.o.js'] + args + if jsrun.TRACK_PROCESS_SPAWNS: + logging.info('Executing emscripten.py compiler with cmdline "' + ' '.join(cmdline) + '"') + compiler_output = jsrun.timeout_run(Popen(cmdline, stdout=PIPE), None, 'Compiling') #print compiler_output # Detect compilation crashes and errors @@ -1511,6 +1510,28 @@ class JS: return ident.replace('%', '$').replace('@', '_') @staticmethod + def make_initializer(sig, settings=None): + settings = settings or Settings + if sig == 'i': + return '0' + elif sig == 'f' and settings.get('PRECISE_F32'): + return 'Math_fround(0)' + else: + return '+0' + + @staticmethod + def make_coercion(value, sig, settings=None): + settings = settings or Settings + if sig == 'i': + return value + '|0' + elif sig == 'f' and settings.get('PRECISE_F32'): + return 'Math_fround(' + value + ')' + elif sig == 'd' or sig == 'f': + return '+' + value + else: + return value + + @staticmethod def make_extcall(sig, named=True): args = ','.join(['a' + str(i) for i in range(1, len(sig))]) args = 'index' + (',' if args else '') + args |