-/**********************************************************************/
-/* Purity of essence, peace on earth */
-/**********************************************************************/
-
-static int symbols_initialized;
-
-Lisp_Object
-make_pure_string (CONST Bufbyte *data, Bytecount length,
- Lisp_Object plist, int no_need_to_copy_data)
-{
- Lisp_Object new;
- struct Lisp_String *s;
- size_t size = sizeof (struct Lisp_String) +
- (no_need_to_copy_data ? 0 : (length + 1)); /* + 1 for terminating 0 */
- size = ALIGN_SIZE (size, ALIGNOF (Lisp_Object));
-
- if (symbols_initialized && !pure_lossage)
- {
- /* Try to share some names. Saves a few kbytes. */
- Lisp_Object tem = oblookup (Vobarray, data, length);
- if (SYMBOLP (tem))
- {
- s = XSYMBOL (tem)->name;
- if (!PURIFIED (s)) abort ();
- XSETSTRING (new, s);
- return new;
- }
- }
-
- if (!check_purespace (size))
- return make_string (data, length);
-
- s = (struct Lisp_String *) (PUREBEG + pure_bytes_used);
-#ifdef LRECORD_STRING
- set_lheader_implementation (&(s->lheader), lrecord_string);
-#ifdef USE_INDEXED_LRECORD_IMPLEMENTATION
- s->lheader.pure = 1;
-#endif
-#endif
- set_string_length (s, length);
- if (no_need_to_copy_data)
- {
- set_string_data (s, (Bufbyte *) data);
- }
- else
- {
- set_string_data (s, (Bufbyte *) s + sizeof (struct Lisp_String));
- memcpy (string_data (s), data, length);
- set_string_byte (s, length, 0);
- }
- s->plist = Qnil;
- pure_bytes_used += size;
-
-#ifdef PURESTAT
- bump_purestat (&purestat_string_all, size);
- if (purecopying_for_bytecode)
- bump_purestat (&purestat_string_other_function, size);
-#endif /* PURESTAT */
-
- /* Do this after the official "completion" of the purecopying. */
- s->plist = Fpurecopy (plist);
-
- XSETSTRING (new, s);
- return new;
-}
-
-
-Lisp_Object
-make_pure_pname (CONST Bufbyte *data, Bytecount length,
- int no_need_to_copy_data)
-{
- Lisp_Object name = make_pure_string (data, length, Qnil,
- no_need_to_copy_data);
- bump_purestat (&purestat_string_pname, pure_sizeof (name));
-
- /* We've made (at least) Qnil now, and Vobarray will soon be set up. */
- symbols_initialized = 1;
-
- return name;
-}
-
-
-Lisp_Object
-pure_cons (Lisp_Object car, Lisp_Object cdr)
-{
- Lisp_Object new;
- struct Lisp_Cons *c;
-
- if (!check_purespace (sizeof (struct Lisp_Cons)))
- return Fcons (Fpurecopy (car), Fpurecopy (cdr));
-
- c = (struct Lisp_Cons *) (PUREBEG + pure_bytes_used);
-#ifdef LRECORD_CONS
- set_lheader_implementation (&(c->lheader), lrecord_cons);
-#ifdef USE_INDEXED_LRECORD_IMPLEMENTATION
- c->lheader.pure = 1;
-#endif
-#endif
- pure_bytes_used += sizeof (struct Lisp_Cons);
- bump_purestat (&purestat_cons, sizeof (struct Lisp_Cons));
-
- c->car = Fpurecopy (car);
- c->cdr = Fpurecopy (cdr);
- XSETCONS (new, c);
- return new;
-}
-
-Lisp_Object
-pure_list (int nargs, Lisp_Object *args)
-{
- Lisp_Object val = Qnil;
-
- for (--nargs; nargs >= 0; nargs--)
- val = pure_cons (args[nargs], val);
-
- return val;
-}
-
-#ifdef LISP_FLOAT_TYPE
-
-static Lisp_Object
-make_pure_float (double num)
-{
- struct Lisp_Float *f;
- Lisp_Object val;
-
- /* Make sure that PUREBEG + pure_bytes_used is aligned on at least a sizeof
- (double) boundary. Some architectures (like the sparc) require
- this, and I suspect that floats are rare enough that it's no
- tragedy for those that don't. */
- {
-#if defined (__GNUC__) && (__GNUC__ >= 2)
- /* In gcc, we can directly ask what the alignment constraints of a
- structure are, but in general, that's not possible... Arrgh!!
- */
- int alignment = __alignof (struct Lisp_Float);
-#else /* !GNUC */
- /* Best guess is to make the `double' slot be aligned to the size
- of double (which is probably 8 bytes). This assumes that it's
- ok to align the beginning of the structure to the same boundary
- that the `double' slot in it is supposed to be aligned to; this
- should be ok because presumably there is padding in the layout
- of the struct to account for this.
- */
- int alignment = sizeof (float_data (f));
-#endif /* !GNUC */
- char *p = ((char *) PUREBEG + pure_bytes_used);
-
- p = (char *) (((EMACS_UINT) p + alignment - 1) & - alignment);
- pure_bytes_used = p - (char *) PUREBEG;
- }
-
- if (!check_purespace (sizeof (struct Lisp_Float)))
- return make_float (num);
-
- f = (struct Lisp_Float *) (PUREBEG + pure_bytes_used);
- set_lheader_implementation (&(f->lheader), lrecord_float);
-#ifdef USE_INDEXED_LRECORD_IMPLEMENTATION
- f->lheader.pure = 1;
-#endif
- pure_bytes_used += sizeof (struct Lisp_Float);
- bump_purestat (&purestat_float, sizeof (struct Lisp_Float));
-
- float_data (f) = num;
- XSETFLOAT (val, f);
- return val;
-}
-
-#endif /* LISP_FLOAT_TYPE */
-
-Lisp_Object
-make_pure_vector (size_t len, Lisp_Object init)
-{
- Lisp_Object new;
- struct Lisp_Vector *v;
- size_t size = (sizeof (struct Lisp_Vector)
- + (len - 1) * sizeof (Lisp_Object));
-
- init = Fpurecopy (init);
-
- if (!check_purespace (size))
- return make_vector (len, init);
-
- v = (struct Lisp_Vector *) (PUREBEG + pure_bytes_used);
-#ifdef LRECORD_VECTOR
- set_lheader_implementation (&(v->header.lheader), lrecord_vector);
-#ifdef USE_INDEXED_LRECORD_IMPLEMENTATION
- v->header.lheader.pure = 1;
-#endif
-#endif
- pure_bytes_used += size;
- bump_purestat (&purestat_vector_all, size);
-
- v->size = len;
-
- for (size = 0; size < len; size++)
- v->contents[size] = init;
-
- XSETVECTOR (new, v);
- return new;
-}
-
-#if 0
-/* Presently unused */
-void *
-alloc_pure_lrecord (int size, struct lrecord_implementation *implementation)
-{
- struct lrecord_header *header = (void *) (PUREBEG + pure_bytes_used);
-
- if (pure_bytes_used + size > get_PURESIZE())
- pure_storage_exhausted ();
-
- set_lheader_implementation (header, implementation);
- header->next = 0;
- return header;
-}
-#endif /* unused */
-