Bug 391488: Eliminate PTRDIFF macro; delete jssttddef.h. r=jimb

Delete jsstddef.h, since its only remaining purpose is to make certain
Win16-specific definitions; we don't support Win16 any more.  In
particular, we can just subtract pointers now, so the PTRDIFF macro is
unnecessary noise.

Most places get stddef.h via jstypes.h or some other header, so we can
just delete #inclusions of jstddef.h.  The exception is jskwgen.h, so
there we explicitly include <stddef.h> instead.
This commit is contained in:
Jim Blandy 2009-02-18 09:14:51 -08:00
parent 9bbf1f94ed
commit c9f53b96cf
44 changed files with 50 additions and 183 deletions

View File

@ -196,7 +196,6 @@ INSTALLED_HEADERS = \
jsscope.h \
jsscript.h \
jsstaticcheck.h \
jsstddef.h \
jsstdint.h \
jsstr.h \
jstracer.h \

View File

@ -243,7 +243,6 @@ OTHER_HFILES = \
jscompat.h \
jscpucfg.h \
jsotypes.h \
jsstddef.h \
prmjtime.h \
resource.h \
jsopcode.tbl \

View File

@ -41,7 +41,6 @@
/*
* JavaScript API.
*/
#include "jsstddef.h"
#include <ctype.h>
#include <stdarg.h>
#include <stdlib.h>
@ -5154,9 +5153,9 @@ JS_ExecuteScriptPart(JSContext *cx, JSObject *obj, JSScript *script,
/* Make a temporary copy of the JSScript structure and farble it a bit. */
tmp = *script;
if (part == JSEXEC_PROLOG) {
tmp.length = PTRDIFF(tmp.main, tmp.code, jsbytecode);
tmp.length = tmp.main - tmp.code;
} else {
tmp.length -= PTRDIFF(tmp.main, tmp.code, jsbytecode);
tmp.length -= tmp.main - tmp.code;
tmp.code = tmp.main;
}

View File

@ -42,7 +42,6 @@
* "Fast Allocation and Deallocation of Memory Based on Object Lifetimes"
* David R. Hanson, Software -- Practice and Experience, Vol. 20(1).
*/
#include "jsstddef.h"
#include <stdlib.h>
#include <string.h>
#include "jstypes.h"

View File

@ -75,7 +75,6 @@
* a js_SlowArrayClass, but have the same performance characteristics as
* a dense array for slot accesses, at some cost in code complexity.
*/
#include "jsstddef.h"
#include <stdlib.h>
#include <string.h>
#include "jstypes.h"

View File

@ -40,7 +40,6 @@
/*
* JS atom table.
*/
#include "jsstddef.h"
#include <stdlib.h>
#include <string.h>
#include "jstypes.h"

View File

@ -40,7 +40,6 @@
/*
* JS boolean implementation.
*/
#include "jsstddef.h"
#include "jstypes.h"
#include "jsutil.h" /* Added by JSIFY */
#include "jsapi.h"

View File

@ -39,7 +39,6 @@
*
* ***** END LICENSE BLOCK ***** */
#include "jsstddef.h"
#include <math.h>
#include "jsapi.h"

View File

@ -41,7 +41,6 @@
/*
* JS execution context.
*/
#include "jsstddef.h"
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>

View File

@ -51,7 +51,6 @@
* Frederick Brooks, 'The Second-System Effect'.
*/
#include "jsstddef.h"
#include <ctype.h>
#include <locale.h>
#include <math.h>

View File

@ -41,7 +41,6 @@
/*
* JS debugging API.
*/
#include "jsstddef.h"
#include <string.h>
#include "jstypes.h"
#include "jsutil.h" /* Added by JSIFY */

View File

@ -40,7 +40,6 @@
/*
* Portable double to alphanumeric string and back converters.
*/
#include "jsstddef.h"
#include "jslibmath.h"
#include "jstypes.h"
#include "jsdtoa.h"

View File

@ -41,7 +41,6 @@
/*
* JS bytecode generation.
*/
#include "jsstddef.h"
#ifdef HAVE_MEMORY_H
#include <memory.h>
#endif
@ -126,7 +125,7 @@ EmitCheck(JSContext *cx, JSCodeGenerator *cg, JSOp op, ptrdiff_t delta)
base = CG_BASE(cg);
next = CG_NEXT(cg);
limit = CG_LIMIT(cg);
offset = PTRDIFF(next, base, jsbytecode);
offset = next - base;
if (next + delta > limit) {
length = offset + delta;
length = (length <= BYTECODE_CHUNK)
@ -136,7 +135,7 @@ EmitCheck(JSContext *cx, JSCodeGenerator *cg, JSOp op, ptrdiff_t delta)
if (!base) {
JS_ARENA_ALLOCATE_CAST(base, jsbytecode *, cg->codePool, incr);
} else {
size = BYTECODE_SIZE(PTRDIFF(limit, base, jsbytecode));
size = BYTECODE_SIZE(limit - base);
incr -= size;
JS_ARENA_GROW_CAST(base, jsbytecode *, cg->codePool, size, incr);
}
@ -557,8 +556,8 @@ AddSpanDep(JSContext *cx, JSCodeGenerator *cg, jsbytecode *pc, jsbytecode *pc2,
cg->numSpanDeps = index + 1;
sd = cg->spanDeps + index;
sd->top = PTRDIFF(pc, CG_BASE(cg), jsbytecode);
sd->offset = sd->before = PTRDIFF(pc2, CG_BASE(cg), jsbytecode);
sd->top = pc - CG_BASE(cg);
sd->offset = sd->before = pc2 - CG_BASE(cg);
if (js_CodeSpec[*pc].format & JOF_BACKPATCH) {
/* Jump offset will be backpatched if off is a non-zero "bpdelta". */
@ -673,7 +672,7 @@ GetSpanDep(JSCodeGenerator *cg, jsbytecode *pc)
if (index != SPANDEP_INDEX_HUGE)
return cg->spanDeps + index;
offset = PTRDIFF(pc, CG_BASE(cg), jsbytecode);
offset = pc - CG_BASE(cg);
lo = 0;
hi = cg->numSpanDeps - 1;
while (lo <= hi) {
@ -910,7 +909,7 @@ OptimizeSpanDeps(JSContext *cx, JSCodeGenerator *cg)
next = base + length;
if (next > limit) {
JS_ASSERT(length > BYTECODE_CHUNK);
size = BYTECODE_SIZE(PTRDIFF(limit, base, jsbytecode));
size = BYTECODE_SIZE(limit - base);
incr = BYTECODE_SIZE(length) - size;
JS_ARENA_GROW_CAST(base, jsbytecode *, cg->codePool, size, incr);
if (!base) {
@ -1429,7 +1428,7 @@ BackPatch(JSContext *cx, JSCodeGenerator *cg, ptrdiff_t last,
stop = CG_CODE(cg, -1);
while (pc != stop) {
delta = GetJumpOffset(cg, pc);
span = PTRDIFF(target, pc, jsbytecode);
span = target - pc;
CHECK_AND_SET_JUMP_OFFSET(cx, cg, pc, span);
/*
@ -6670,7 +6669,7 @@ js_SetSrcNoteOffset(JSContext *cx, JSCodeGenerator *cg, uintN index,
/* Maybe this offset was already set to a three-byte value. */
if (!(*sn & SN_3BYTE_OFFSET_FLAG)) {
/* Losing, need to insert another two bytes for this offset. */
index = PTRDIFF(sn, CG_NOTES(cg), jssrcnote);
index = sn - CG_NOTES(cg);
/*
* Simultaneously test to see if the source note array must grow to

View File

@ -43,8 +43,6 @@
/*
* JS bytecode generation.
*/
#include "jsstddef.h"
#include "jstypes.h"
#include "jsatom.h"
#include "jsopcode.h"
@ -379,7 +377,7 @@ struct JSCodeGenerator {
#define CG_LIMIT(cg) ((cg)->current->limit)
#define CG_NEXT(cg) ((cg)->current->next)
#define CG_CODE(cg,offset) (CG_BASE(cg) + (offset))
#define CG_OFFSET(cg) PTRDIFF(CG_NEXT(cg), CG_BASE(cg), jsbytecode)
#define CG_OFFSET(cg) (CG_NEXT(cg) - CG_BASE(cg))
#define CG_NOTES(cg) ((cg)->current->notes)
#define CG_NOTE_COUNT(cg) ((cg)->current->noteCount)
@ -391,8 +389,7 @@ struct JSCodeGenerator {
#define CG_PROLOG_LIMIT(cg) ((cg)->prolog.limit)
#define CG_PROLOG_NEXT(cg) ((cg)->prolog.next)
#define CG_PROLOG_CODE(cg,poff) (CG_PROLOG_BASE(cg) + (poff))
#define CG_PROLOG_OFFSET(cg) PTRDIFF(CG_PROLOG_NEXT(cg), CG_PROLOG_BASE(cg),\
jsbytecode)
#define CG_PROLOG_OFFSET(cg) (CG_PROLOG_NEXT(cg) - CG_PROLOG_BASE(cg))
#define CG_SWITCH_TO_MAIN(cg) ((cg)->current = &(cg)->main)
#define CG_SWITCH_TO_PROLOG(cg) ((cg)->current = &(cg)->prolog)

View File

@ -42,7 +42,6 @@
* JS standard exception implementation.
*/
#include "jsstddef.h"
#include <stdlib.h>
#include <string.h>
#include "jstypes.h"

View File

@ -43,7 +43,6 @@
*/
#if JS_HAS_FILE_OBJECT
#include "jsstddef.h"
#include "jsfile.h"
/* ----------------- Platform-specific includes and defines ----------------- */

View File

@ -41,7 +41,6 @@
/*
* JS function support.
*/
#include "jsstddef.h"
#include <string.h>
#include "jstypes.h"
#include "jsbit.h"

View File

@ -48,7 +48,6 @@
*
* XXX swizzle page to freelist for better locality of reference
*/
#include "jsstddef.h"
#include <stdlib.h> /* for free */
#include <math.h>
#include <string.h> /* for memset used when DEBUG */

View File

@ -40,7 +40,6 @@
/*
* PR hash table package.
*/
#include "jsstddef.h"
#include <stdlib.h>
#include <string.h>
#include "jstypes.h"

View File

@ -41,7 +41,6 @@
/*
* JavaScript bytecode interpreter.
*/
#include "jsstddef.h"
#include <stdio.h>
#include <string.h>
#include <math.h>
@ -350,7 +349,7 @@ js_FullTestPropertyCache(JSContext *cx, jsbytecode *pc,
entry->kshape,
OBJ_SHAPE(obj));
js_Disassemble1(cx, cx->fp->script, pc,
PTRDIFF(pc, cx->fp->script->code, jsbytecode),
pc - cx->fp->script->code,
JS_FALSE, stderr);
#endif
@ -2060,7 +2059,7 @@ js_TraceOpcode(JSContext *cx, jsint len)
fprintf(tracefp, "%4u: ",
js_PCToLineNumber(cx, fp->script, fp->imacpc ? fp->imacpc : regs->pc));
js_Disassemble1(cx, fp->script, regs->pc,
PTRDIFF(regs->pc, fp->script->code, jsbytecode),
regs->pc - fp->script->code,
JS_FALSE, tracefp);
op = (JSOp) *regs->pc;
nuses = js_CodeSpec[op].nuses;
@ -6351,14 +6350,14 @@ js_Interpret(JSContext *cx)
BEGIN_CASE(JSOP_GOSUB)
PUSH(JSVAL_FALSE);
i = PTRDIFF(regs.pc, script->main, jsbytecode) + JSOP_GOSUB_LENGTH;
i = (regs.pc - script->main) + JSOP_GOSUB_LENGTH;
PUSH(INT_TO_JSVAL(i));
len = GET_JUMP_OFFSET(regs.pc);
END_VARLEN_CASE
BEGIN_CASE(JSOP_GOSUBX)
PUSH(JSVAL_FALSE);
i = PTRDIFF(regs.pc, script->main, jsbytecode) + JSOP_GOSUBX_LENGTH;
i = (regs.pc - script->main) + JSOP_GOSUBX_LENGTH;
len = GET_JUMPX_OFFSET(regs.pc);
PUSH(INT_TO_JSVAL(i));
END_VARLEN_CASE

View File

@ -41,7 +41,6 @@
/*
* JavaScript iterators.
*/
#include "jsstddef.h"
#include <string.h> /* for memcpy */
#include "jstypes.h"
#include "jsutil.h"

View File

@ -38,7 +38,7 @@
*
* ***** END LICENSE BLOCK ***** */
#include "jsstddef.h"
#include <stddef.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

View File

@ -42,7 +42,6 @@
/*
* JS locking stubs.
*/
#include "jsstddef.h"
#include <stdlib.h>
#include <string.h>
#include "jspubtd.h"

View File

@ -36,7 +36,6 @@
*
* ***** END LICENSE BLOCK ***** */
#include "jsstddef.h"
#include "jsbit.h"
#include "jsutil.h"

View File

@ -40,7 +40,6 @@
/*
* JS math package.
*/
#include "jsstddef.h"
#include "jslibmath.h"
#include <stdlib.h>
#include "jstypes.h"

View File

@ -41,7 +41,6 @@
/*
* JS number type and wrapper class.
*/
#include "jsstddef.h"
#if defined(XP_WIN) || defined(XP_OS2)
#include <float.h>
#endif

View File

@ -41,7 +41,6 @@
/*
* JS object implementation.
*/
#include "jsstddef.h"
#include <stdlib.h>
#include <string.h>
#include "jstypes.h"

View File

@ -41,7 +41,6 @@
/*
* JS bytecode descriptors, disassemblers, and decompilers.
*/
#include "jsstddef.h"
#ifdef HAVE_MEMORY_H
#include <memory.h>
#endif
@ -235,7 +234,7 @@ js_Disassemble(JSContext *cx, JSScript *script, JSBool lines, FILE *fp)
if (pc == script->main)
fputs("main:\n", fp);
len = js_Disassemble1(cx, script, pc,
PTRDIFF(pc, script->code, jsbytecode),
pc - script->code,
lines, fp);
if (!len)
return JS_FALSE;
@ -618,7 +617,7 @@ QuoteString(Sprinter *sp, JSString *str, uint32 quote)
if (t == z)
break;
}
len = PTRDIFF(t, s, jschar);
len = t - s;
/* Allocate space for s, including the '\0' at the end. */
if (!SprintEnsureBuffer(sp, len))
@ -2678,7 +2677,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
len = js_GetSrcNoteOffset(sn, 0);
if (len) {
len -= PTRDIFF(pc, pc2, jsbytecode);
len -= pc - pc2;
LOCAL_ASSERT_OUT(len > 0);
js_printf(jp, " if ");
ok = Decompile(ss, pc, len, JSOP_NOP) != NULL;
@ -3256,7 +3255,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop)
return NULL;
done = pc + GetJumpOffset(pc, pc);
pc += len;
len = PTRDIFF(done, pc, jsbytecode);
len = done - pc;
if (!Decompile(ss, pc, len, op)) {
JS_free(cx, (char *)lval);
return NULL;
@ -5138,7 +5137,7 @@ DecompileExpression(JSContext *cx, JSScript *script, JSFunction *fun,
break;
default:;
}
len = PTRDIFF(end, begin, jsbytecode);
len = end - begin;
if (len <= 0) {
name = FAILED_EXPRESSION_DECOMPILER;
goto out;

View File

@ -51,7 +51,6 @@
*
* This parser attempts no error recovery.
*/
#include "jsstddef.h"
#include <stdlib.h>
#include <string.h>
#include <math.h>

View File

@ -41,7 +41,6 @@
**
** Author: Kipp E.B. Hickman
*/
#include "jsstddef.h"
#include <stdarg.h>
#include <stdio.h>
#include <string.h>

View File

@ -41,7 +41,6 @@
/*
* JS regular expressions, after Perl.
*/
#include "jsstddef.h"
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>

View File

@ -41,7 +41,6 @@
/*
* JS lexical scanner.
*/
#include "jsstddef.h"
#include <stdio.h> /* first to avoid trouble on some systems */
#include <errno.h>
#include <limits.h>
@ -186,14 +185,14 @@ GrowTokenBuf(JSStringBuffer *sb, size_t newlength)
cx = (JSContext*) sb->data;
base = sb->base;
offset = PTRDIFF(sb->ptr, base, jschar);
offset = sb->ptr - base;
pool = &cx->tempPool;
if (!base) {
tbsize = TBMIN * sizeof(jschar);
length = TBMIN - 1;
JS_ARENA_ALLOCATE_CAST(base, jschar *, pool, tbsize);
} else {
length = PTRDIFF(sb->limit, base, jschar);
length = sb->limit - base;
if ((size_t)length >= ~(size_t)0 / sizeof(jschar)) {
base = NULL;
} else {
@ -300,7 +299,7 @@ GetChar(JSTokenStream *ts)
c = ts->ungetbuf[--ts->ungetpos];
} else {
if (ts->linebuf.ptr == ts->linebuf.limit) {
len = PTRDIFF(ts->userbuf.limit, ts->userbuf.ptr, jschar);
len = ts->userbuf.limit - ts->userbuf.ptr;
if (len <= 0) {
if (!ts->file) {
ts->flags |= TSF_EOF;
@ -366,7 +365,7 @@ GetChar(JSTokenStream *ts)
* Else copy JS_LINE_LIMIT-1 bytes into linebuf.
*/
if (nl < ts->userbuf.limit)
len = PTRDIFF(nl, ts->userbuf.ptr, jschar) + 1;
len = (nl - ts->userbuf.ptr) + 1;
if (len >= JS_LINE_LIMIT) {
len = JS_LINE_LIMIT - 1;
ts->saveEOL = nl;
@ -559,7 +558,7 @@ js_ReportCompileErrorNumber(JSContext *cx, JSTokenStream *ts, JSParseNode *pn,
tp = &ts->tokens[ts->cursor].pos;
}
report.lineno = ts->lineno;
linelength = PTRDIFF(ts->linebuf.limit, ts->linebuf.base, jschar);
linelength = ts->linebuf.limit - ts->linebuf.base;
linechars = (jschar *)JS_malloc(cx, (linelength + 1) * sizeof(jschar));
if (!linechars) {
warning = JS_FALSE;
@ -680,7 +679,7 @@ GrowStringBuffer(JSStringBuffer *sb, size_t newlength)
ptrdiff_t offset;
jschar *bp;
offset = PTRDIFF(sb->ptr, sb->base, jschar);
offset = sb->ptr - sb->base;
JS_ASSERT(offset >= 0);
newlength += offset + 1;
if ((size_t)offset < newlength && newlength < ~(size_t)0 / sizeof(jschar))
@ -816,7 +815,7 @@ GetXMLEntity(JSContext *cx, JSTokenStream *ts)
JSErrNum msg;
/* Put the entity, including the '&' already scanned, in ts->tokenbuf. */
offset = PTRDIFF(ts->tokenbuf.ptr, ts->tokenbuf.base, jschar);
offset = ts->tokenbuf.ptr - ts->tokenbuf.base;
FastAppendChar(&ts->tokenbuf, '&');
if (!STRING_BUFFER_OK(&ts->tokenbuf))
return JS_FALSE;
@ -832,7 +831,7 @@ GetXMLEntity(JSContext *cx, JSTokenStream *ts)
}
/* Let length be the number of jschars after the '&', including the ';'. */
length = PTRDIFF(ts->tokenbuf.ptr, ts->tokenbuf.base, jschar) - offset;
length = (ts->tokenbuf.ptr - ts->tokenbuf.base) - offset;
bp = ts->tokenbuf.base + offset;
c = d = 0;
ispair = JS_FALSE;
@ -915,9 +914,9 @@ badncr:
bad:
/* No match: throw a TypeError per ECMA-357 10.3.2.1 step 8(a). */
JS_ASSERT(STRING_BUFFER_OK(&ts->tokenbuf));
JS_ASSERT(PTRDIFF(ts->tokenbuf.ptr, bp, jschar) >= 1);
JS_ASSERT((ts->tokenbuf.ptr - bp) >= 1);
bytes = js_DeflateString(cx, bp + 1,
PTRDIFF(ts->tokenbuf.ptr, bp, jschar) - 1);
(ts->tokenbuf.ptr - bp) - 1);
if (bytes) {
js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR,
msg, bytes);
@ -989,7 +988,7 @@ NewToken(JSTokenStream *ts, ptrdiff_t adjust)
tp = &CURRENT_TOKEN(ts);
tp->ptr = ts->linebuf.ptr + adjust;
tp->pos.begin.index = ts->linepos +
PTRDIFF(tp->ptr, ts->linebuf.base, jschar) -
(tp->ptr - ts->linebuf.base) -
ts->ungetpos;
tp->pos.begin.lineno = tp->pos.end.lineno = (uint16)ts->lineno;
return tp;
@ -1020,7 +1019,7 @@ js_GetToken(JSContext *cx, JSTokenStream *ts)
#endif
#define INIT_TOKENBUF() (ts->tokenbuf.ptr = ts->tokenbuf.base)
#define TOKENBUF_LENGTH() PTRDIFF(ts->tokenbuf.ptr, ts->tokenbuf.base, jschar)
#define TOKENBUF_LENGTH() (ts->tokenbuf.ptr - ts->tokenbuf.base)
#define TOKENBUF_OK() STRING_BUFFER_OK(&ts->tokenbuf)
#define TOKENBUF_TO_ATOM() (TOKENBUF_OK() \
? js_AtomizeChars(cx, \
@ -1986,7 +1985,7 @@ eol_out:
tt = TOK_ERROR;
JS_ASSERT(tt < TOK_LIMIT);
tp->pos.end.index = ts->linepos +
PTRDIFF(ts->linebuf.ptr, ts->linebuf.base, jschar) -
(ts->linebuf.ptr - ts->linebuf.base) -
ts->ungetpos;
tp->type = tt;
return tt;

View File

@ -41,7 +41,6 @@
/*
* JS symbol tables.
*/
#include "jsstddef.h"
#include <stdlib.h>
#include <string.h>
#include "jstypes.h"

View File

@ -41,7 +41,6 @@
/*
* JS script operations.
*/
#include "jsstddef.h"
#include <string.h>
#include "jstypes.h"
#include "jsutil.h" /* Added by JSIFY */
@ -453,7 +452,7 @@ js_XDRScript(JSXDRState *xdr, JSScript **scriptp, JSBool *hasMagic)
if (xdr->mode == JSXDR_ENCODE) {
length = script->length;
prologLength = PTRDIFF(script->main, script->code, jsbytecode);
prologLength = script->main - script->code;
JS_ASSERT((int16)script->version != JSVERSION_UNKNOWN);
version = (uint32)script->version | (script->nfixed << 16);
lineno = (uint32)script->lineno;
@ -465,7 +464,7 @@ js_XDRScript(JSXDRState *xdr, JSScript **scriptp, JSBool *hasMagic)
notes = SCRIPT_NOTES(script);
for (sn = notes; !SN_IS_TERMINATOR(sn); sn = SN_NEXT(sn))
continue;
nsrcnotes = PTRDIFF(sn, notes, jssrcnote);
nsrcnotes = sn - notes;
nsrcnotes++; /* room for the terminator */
if (script->objectsOffset != 0)
@ -1687,7 +1686,7 @@ js_GetSrcNoteCached(JSContext *cx, JSScript *script, jsbytecode *pc)
uintN nsrcnotes;
target = PTRDIFF(pc, script->code, jsbytecode);
target = pc - script->code;
if ((uint32)target >= script->length)
return NULL;
@ -1784,7 +1783,7 @@ js_PCToLineNumber(JSContext *cx, JSScript *script, jsbytecode *pc)
*/
lineno = script->lineno;
offset = 0;
target = PTRDIFF(pc, script->code, jsbytecode);
target = pc - script->code;
for (sn = SCRIPT_NOTES(script); !SN_IS_TERMINATOR(sn); sn = SN_NEXT(sn)) {
offset += SN_DELTA(sn);
type = (JSSrcNoteType) SN_TYPE(sn);

View File

@ -1,87 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Communicator client code, released
* March 31, 1998.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* stddef inclusion here to first declare ptrdif as a signed long instead of a
* signed int.
*/
#ifdef _WINDOWS
# ifndef XP_WIN
# define XP_WIN
# endif
#if defined(_WIN32) || defined(WIN32)
# ifndef XP_WIN32
# define XP_WIN32
# endif
#else
# ifndef XP_WIN16
# define XP_WIN16
# endif
#endif
#endif
#ifdef XP_WIN16
#ifndef _PTRDIFF_T_DEFINED
typedef long ptrdiff_t;
/*
* The Win16 compiler treats pointer differences as 16-bit signed values.
* This macro allows us to treat them as 17-bit signed values, stored in
* a 32-bit type.
*/
#define PTRDIFF(p1, p2, type) \
((((unsigned long)(p1)) - ((unsigned long)(p2))) / sizeof(type))
#define _PTRDIFF_T_DEFINED
#endif /*_PTRDIFF_T_DEFINED*/
#else /*WIN16*/
#define PTRDIFF(p1, p2, type) \
((p1) - (p2))
#endif
#include <stddef.h>
#ifdef __cplusplus
# define __cplusplus_only(x) x
#else
# define __cplusplus_only(x) /* nothing */
#endif

View File

@ -48,7 +48,6 @@
* of rooting things that might lose their newborn root due to subsequent GC
* allocations in the same native method.
*/
#include "jsstddef.h"
#include <stdlib.h>
#include <string.h>
#include "jstypes.h"

View File

@ -39,7 +39,6 @@
*
* ***** END LICENSE BLOCK ***** */
#include "jsstddef.h" // always first
#include "jsbit.h" // low-level (NSPR-based) headers next
#include "jsprf.h"
#include <math.h> // standard headers next
@ -4328,9 +4327,7 @@ TraceRecorder::monitorRecording(JSContext* cx, TraceRecorder* tr, JSOp op)
js_Disassemble1(cx, cx->fp->script, cx->fp->regs->pc, \
(cx->fp->imacpc) \
? 0 \
: PTRDIFF(cx->fp->regs->pc, \
cx->fp->script->code, \
jsbytecode), \
: cx->fp->regs->pc - cx->fp->script->code, \
!cx->fp->imacpc, stdout);) \
flag = tr->record_##x(); \
if (x == JSOP_ITER || x == JSOP_NEXTITER || x == JSOP_APPLY || \

View File

@ -45,7 +45,6 @@
#ifdef JS_TRACER
#include "jscntxt.h"
#include "jsstddef.h"
#include "jstypes.h"
#include "jslock.h"
#include "jsnum.h"

View File

@ -41,7 +41,6 @@
/*
* PR assertion checker.
*/
#include "jsstddef.h"
#include <stdio.h>
#include <stdlib.h>
#include "jstypes.h"

View File

@ -36,7 +36,6 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "jsstddef.h"
#include "jsversion.h"
#if JS_HAS_XDR

View File

@ -37,7 +37,6 @@
*
* ***** END LICENSE BLOCK ***** */
#include "jsstddef.h"
#include "jsversion.h"
#if JS_HAS_XML_SUPPORT
@ -1279,7 +1278,7 @@ ParseNodeToQName(JSContext *cx, JSParseContext *pc, JSParseNode *pn,
limit = start + length;
colon = js_strchr_limit(start, ':', limit);
if (colon) {
offset = PTRDIFF(colon, start, jschar);
offset = colon - start;
prefix = js_NewDependentString(cx, str, 0, offset);
if (!prefix)
return NULL;
@ -1371,10 +1370,10 @@ ChompXMLWhitespace(JSContext *cx, JSString *str)
break;
--end;
}
newlength = PTRDIFF(end, cp, jschar);
newlength = end - cp;
if (newlength == length)
return str;
offset = PTRDIFF(cp, start, jschar);
offset = cp - start;
return js_NewDependentString(cx, str, offset, newlength);
}
@ -2460,13 +2459,13 @@ GeneratePrefix(JSContext *cx, JSString *uri, JSXMLArray *decls)
while (--cp > start) {
if (*cp == '.' || *cp == '/' || *cp == ':') {
++cp;
length = PTRDIFF(end, cp, jschar);
length = end - cp;
if (IsXMLName(cp, length) && !STARTS_WITH_XML(cp, length))
break;
end = --cp;
}
}
length = PTRDIFF(end, cp, jschar);
length = end - cp;
/*
* If the namespace consisted only of non-XML names or names that begin
@ -2527,7 +2526,7 @@ GeneratePrefix(JSContext *cx, JSString *uri, JSXMLArray *decls)
} while (!done);
if (bp == cp) {
offset = PTRDIFF(cp, start, jschar);
offset = cp - start;
prefix = js_NewDependentString(cx, uri, offset, length);
} else {
prefix = js_NewString(cx, bp, newlength);

View File

@ -39,7 +39,6 @@
#ifndef jsxml_h___
#define jsxml_h___
#include "jsstddef.h"
#include "jspubtd.h"
JS_BEGIN_EXTERN_C

View File

@ -40,7 +40,6 @@
/*
* PR time code.
*/
#include "jsstddef.h"
#ifdef SOLARIS
#define _REENTRANT 1
#endif

View File

@ -41,7 +41,6 @@
/*
* JS shell.
*/
#include "jsstddef.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@ -1377,7 +1376,7 @@ LineToPC(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
pc = JS_LineNumberToPC(cx, script, lineno);
if (!pc)
return JS_FALSE;
*rval = INT_TO_JSVAL(PTRDIFF(pc, script->code, jsbytecode));
*rval = INT_TO_JSVAL(pc - script->code);
return JS_TRUE;
}
@ -1476,7 +1475,7 @@ SrcNotes(JSContext *cx, JSScript *script)
}
}
fprintf(gOutFile, "%3u: %5u [%4u] %-8s",
(uintN) PTRDIFF(sn, notes, jssrcnote), offset, delta, name);
(uintN) (sn - notes), offset, delta, name);
switch (type) {
case SRC_SETLINE:
fprintf(gOutFile, " lineno %u", (uintN) js_GetSrcNoteOffset(sn, 0));
@ -1746,7 +1745,7 @@ DisassWithSrc(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
}
len = js_Disassemble1(cx, script, pc,
PTRDIFF(pc, script->code, jsbytecode),
pc - script->code,
JS_TRUE, stdout);
if (!len) {
ok = JS_FALSE;
@ -3967,7 +3966,7 @@ my_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
report->linebuf,
(n > 0 && report->linebuf[n-1] == '\n') ? "" : "\n",
prefix);
n = PTRDIFF(report->tokenptr, report->linebuf, char);
n = report->tokenptr - report->linebuf;
for (i = j = 0; i < n; i++) {
if (report->linebuf[i] == '\t') {
for (k = (j + 8) & ~7; j < k; j++) {