deprecated.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  1. /* Copyright 2003-2004,2006,2008-2018,2020,2021
  2. Free Software Foundation, Inc.
  3. This file is part of Guile.
  4. Guile is free software: you can redistribute it and/or modify it
  5. under the terms of the GNU Lesser General Public License as published
  6. by the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. Guile is distributed in the hope that it will be useful, but WITHOUT
  9. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
  11. License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with Guile. If not, see
  14. <https://www.gnu.org/licenses/>. */
  15. #ifdef HAVE_CONFIG_H
  16. # include <config.h>
  17. #endif
  18. #include <stdio.h>
  19. #include <string.h>
  20. #include <unistd.h>
  21. #define SCM_BUILDING_DEPRECATED_CODE
  22. #include "alist.h"
  23. #include "array-handle.h"
  24. #include "arrays.h"
  25. #include "boolean.h"
  26. #include "bitvectors.h"
  27. #include "deprecation.h"
  28. #include "dynl.h"
  29. #include "eval.h"
  30. #include "foreign.h"
  31. #include "generalized-vectors.h"
  32. #include "gc.h"
  33. #include "gsubr.h"
  34. #include "modules.h"
  35. #include "procprop.h"
  36. #include "srcprop.h"
  37. #include "srfi-4.h"
  38. #include "strings.h"
  39. #include "symbols.h"
  40. #include "uniform.h"
  41. #include "vectors.h"
  42. #include "deprecated.h"
  43. #if (SCM_ENABLE_DEPRECATED == 1)
  44. #ifndef MAXPATHLEN
  45. #define MAXPATHLEN 80
  46. #endif /* ndef MAXPATHLEN */
  47. #ifndef X_OK
  48. #define X_OK 1
  49. #endif /* ndef X_OK */
  50. char *
  51. scm_find_executable (const char *name)
  52. {
  53. char tbuf[MAXPATHLEN];
  54. int i = 0, c;
  55. FILE *f;
  56. scm_c_issue_deprecation_warning ("scm_find_executable is deprecated.");
  57. /* fprintf(stderr, "s_f_e checking access %s ->%d\n", name, access(name, X_OK)); fflush(stderr); */
  58. if (access (name, X_OK))
  59. return 0L;
  60. f = fopen (name, "r");
  61. if (!f)
  62. return 0L;
  63. if ((fgetc (f) == '#') && (fgetc (f) == '!'))
  64. {
  65. while (1)
  66. switch (c = fgetc (f))
  67. {
  68. case /*WHITE_SPACES */ ' ':
  69. case '\t':
  70. case '\r':
  71. case '\f':
  72. case EOF:
  73. tbuf[i] = 0;
  74. fclose (f);
  75. return strdup (tbuf);
  76. default:
  77. tbuf[i++] = c;
  78. break;
  79. }
  80. }
  81. fclose (f);
  82. return strdup (name);
  83. }
  84. int
  85. scm_is_simple_vector (SCM obj)
  86. {
  87. scm_c_issue_deprecation_warning
  88. ("scm_is_simple_vector is deprecated. Use scm_is_vector instead.");
  89. return SCM_I_IS_VECTOR (obj);
  90. }
  91. SCM
  92. scm_bitvector_p (SCM vec)
  93. {
  94. scm_c_issue_deprecation_warning
  95. ("scm_bitvector_p is deprecated. Use scm_is_bitvector instead.");
  96. return scm_from_bool (scm_is_bitvector (vec));
  97. }
  98. SCM
  99. scm_bitvector (SCM list)
  100. {
  101. scm_c_issue_deprecation_warning
  102. ("scm_bitvector is deprecated. Use scm_list_to_bitvector instead.");
  103. return scm_list_to_bitvector (list);
  104. }
  105. SCM
  106. scm_make_bitvector (SCM len, SCM fill)
  107. {
  108. scm_c_issue_deprecation_warning
  109. ("scm_make_bitvector is deprecated. Use scm_c_make_bitvector instead.");
  110. return scm_c_make_bitvector (scm_to_size_t (len), fill);
  111. }
  112. SCM
  113. scm_bitvector_length (SCM vec)
  114. {
  115. scm_c_issue_deprecation_warning
  116. ("scm_bitvector_length is deprecated. Use scm_c_bitvector_length "
  117. "instead.");
  118. return scm_from_size_t (scm_c_bitvector_length (vec));
  119. }
  120. SCM
  121. scm_c_bitvector_ref (SCM vec, size_t idx)
  122. {
  123. scm_c_issue_deprecation_warning
  124. ("bitvector-ref is deprecated. Use bitvector-bit-set? instead.");
  125. if (scm_is_bitvector (vec))
  126. return scm_from_bool (scm_c_bitvector_bit_is_set (vec, idx));
  127. SCM res;
  128. scm_t_array_handle handle;
  129. size_t len, off;
  130. ssize_t inc;
  131. const uint32_t *bits =
  132. scm_bitvector_elements (vec, &handle, &off, &len, &inc);
  133. if (idx >= len)
  134. scm_out_of_range (NULL, scm_from_size_t (idx));
  135. idx = idx*inc + off;
  136. res = scm_from_bool (bits[idx/32] & (1L << (idx%32)));
  137. scm_array_handle_release (&handle);
  138. return res;
  139. }
  140. SCM_DEFINE (scm_bitvector_ref, "bitvector-ref", 2, 0, 0,
  141. (SCM vec, SCM idx),
  142. "Return the element at index @var{idx} of the bitvector\n"
  143. "@var{vec}.")
  144. #define FUNC_NAME s_scm_bitvector_ref
  145. {
  146. return scm_c_bitvector_ref (vec, scm_to_size_t (idx));
  147. }
  148. #undef FUNC_NAME
  149. void
  150. scm_c_bitvector_set_x (SCM vec, size_t idx, SCM val)
  151. {
  152. scm_c_issue_deprecation_warning
  153. ("bitvector-set! is deprecated. Use bitvector-set-bit! or "
  154. "bitvector-clear-bit! instead.");
  155. if (scm_is_bitvector (vec))
  156. {
  157. if (scm_is_true (val))
  158. scm_c_bitvector_set_bit_x (vec, idx);
  159. else
  160. scm_c_bitvector_clear_bit_x (vec, idx);
  161. }
  162. else
  163. {
  164. scm_t_array_handle handle;
  165. uint32_t *bits, mask;
  166. size_t len, off;
  167. ssize_t inc;
  168. bits = scm_bitvector_writable_elements (vec, &handle, &off, &len, &inc);
  169. if (idx >= len)
  170. scm_out_of_range (NULL, scm_from_size_t (idx));
  171. idx = idx*inc + off;
  172. mask = 1L << (idx%32);
  173. if (scm_is_true (val))
  174. bits[idx/32] |= mask;
  175. else
  176. bits[idx/32] &= ~mask;
  177. scm_array_handle_release (&handle);
  178. }
  179. }
  180. SCM_DEFINE (scm_bitvector_set_x, "bitvector-set!", 3, 0, 0,
  181. (SCM vec, SCM idx, SCM val),
  182. "Set the element at index @var{idx} of the bitvector\n"
  183. "@var{vec} when @var{val} is true, else clear it.")
  184. #define FUNC_NAME s_scm_bitvector_set_x
  185. {
  186. scm_c_bitvector_set_x (vec, scm_to_size_t (idx), val);
  187. return SCM_UNSPECIFIED;
  188. }
  189. #undef FUNC_NAME
  190. SCM_DEFINE (scm_bitvector_fill_x, "bitvector-fill!", 2, 0, 0,
  191. (SCM vec, SCM val),
  192. "Set all elements of the bitvector\n"
  193. "@var{vec} when @var{val} is true, else clear them.")
  194. #define FUNC_NAME s_scm_bitvector_fill_x
  195. {
  196. scm_c_issue_deprecation_warning
  197. ("bitvector-fill! is deprecated. Use bitvector-set-all-bits! or "
  198. "bitvector-clear-all-bits! instead.");
  199. if (scm_is_bitvector (vec))
  200. {
  201. if (scm_is_true (val))
  202. scm_c_bitvector_set_all_bits_x (vec);
  203. else
  204. scm_c_bitvector_clear_all_bits_x (vec);
  205. return SCM_UNSPECIFIED;
  206. }
  207. scm_t_array_handle handle;
  208. size_t off, len;
  209. ssize_t inc;
  210. scm_bitvector_writable_elements (vec, &handle, &off, &len, &inc);
  211. size_t i;
  212. for (i = 0; i < len; i++)
  213. scm_array_handle_set (&handle, i*inc, val);
  214. scm_array_handle_release (&handle);
  215. return SCM_UNSPECIFIED;
  216. }
  217. #undef FUNC_NAME
  218. SCM_DEFINE (scm_bit_invert_x, "bit-invert!", 1, 0, 0,
  219. (SCM v),
  220. "Modify the bit vector @var{v} by replacing each element with\n"
  221. "its negation.")
  222. #define FUNC_NAME s_scm_bit_invert_x
  223. {
  224. scm_c_issue_deprecation_warning
  225. ("bit-invert! is deprecated. Use bitvector-flip-all-bits!, or "
  226. "scalar array accessors in a loop for generic arrays.");
  227. if (scm_is_bitvector (v))
  228. scm_c_bitvector_flip_all_bits_x (v);
  229. else
  230. {
  231. size_t off, len;
  232. ssize_t inc;
  233. scm_t_array_handle handle;
  234. scm_bitvector_writable_elements (v, &handle, &off, &len, &inc);
  235. for (size_t i = 0; i < len; i++)
  236. scm_array_handle_set (&handle, i*inc,
  237. scm_not (scm_array_handle_ref (&handle, i*inc)));
  238. scm_array_handle_release (&handle);
  239. }
  240. return SCM_UNSPECIFIED;
  241. }
  242. #undef FUNC_NAME
  243. SCM_DEFINE (scm_bit_count, "bit-count", 2, 0, 0,
  244. (SCM b, SCM bitvector),
  245. "Return the number of occurrences of the boolean @var{b} in\n"
  246. "@var{bitvector}.")
  247. #define FUNC_NAME s_scm_bit_count
  248. {
  249. int bit = scm_to_bool (b);
  250. size_t count = 0, len;
  251. scm_c_issue_deprecation_warning
  252. ("bit-count is deprecated. Use bitvector-count, or a loop over array-ref "
  253. "if array support is needed.");
  254. if (scm_is_bitvector (bitvector))
  255. {
  256. len = scm_to_size_t (scm_bitvector_length (bitvector));
  257. count = scm_c_bitvector_count (bitvector);
  258. }
  259. else
  260. {
  261. scm_t_array_handle handle;
  262. size_t off;
  263. ssize_t inc;
  264. scm_bitvector_elements (bitvector, &handle, &off, &len, &inc);
  265. for (size_t i = 0; i < len; i++)
  266. if (scm_is_true (scm_array_handle_ref (&handle, i*inc)))
  267. count++;
  268. scm_array_handle_release (&handle);
  269. }
  270. return scm_from_size_t (bit ? count : len-count);
  271. }
  272. #undef FUNC_NAME
  273. SCM_DEFINE (scm_bit_count_star, "bit-count*", 3, 0, 0,
  274. (SCM v, SCM kv, SCM obj),
  275. "Return a count of how many entries in bit vector @var{v} are\n"
  276. "equal to @var{obj}, with @var{kv} selecting the entries to\n"
  277. "consider.\n"
  278. "\n"
  279. "If @var{kv} is a bit vector, then those entries where it has\n"
  280. "@code{#t} are the ones in @var{v} which are considered.\n"
  281. "@var{kv} and @var{v} must be the same length.\n"
  282. "\n"
  283. "If @var{kv} is a u32vector, then it contains\n"
  284. "the indexes in @var{v} to consider.\n"
  285. "\n"
  286. "For example,\n"
  287. "\n"
  288. "@example\n"
  289. "(bit-count* #*01110111 #*11001101 #t) @result{} 3\n"
  290. "(bit-count* #*01110111 #u32(7 0 4) #f) @result{} 2\n"
  291. "@end example")
  292. #define FUNC_NAME s_scm_bit_count_star
  293. {
  294. size_t count = 0;
  295. scm_c_issue_deprecation_warning
  296. ("bit-count* is deprecated. Use bitvector-count-bits instead, and in the "
  297. "case of counting false bits, subtract from a bitvector-count on the "
  298. "selection bitvector.");
  299. /* Validate that OBJ is a boolean so this is done even if we don't
  300. need BIT.
  301. */
  302. int bit = scm_to_bool (obj);
  303. if (scm_is_bitvector (v) && scm_is_bitvector (kv))
  304. {
  305. count = scm_c_bitvector_count_bits (v, kv);
  306. if (count == 0)
  307. count = scm_c_bitvector_count (kv) - count;
  308. }
  309. else
  310. {
  311. scm_t_array_handle v_handle;
  312. size_t v_off, v_len;
  313. ssize_t v_inc;
  314. scm_bitvector_elements (v, &v_handle, &v_off, &v_len, &v_inc);
  315. if (scm_is_bitvector (kv))
  316. {
  317. size_t kv_len = scm_c_bitvector_length (kv);
  318. for (size_t i = 0; i < kv_len; i++)
  319. if (scm_c_bitvector_bit_is_set (kv, i))
  320. {
  321. SCM elt = scm_array_handle_ref (&v_handle, i*v_inc);
  322. if ((bit && scm_is_true (elt)) || (!bit && scm_is_false (elt)))
  323. count++;
  324. }
  325. }
  326. else if (scm_is_true (scm_u32vector_p (kv)))
  327. {
  328. scm_t_array_handle kv_handle;
  329. size_t i, kv_len;
  330. ssize_t kv_inc;
  331. const uint32_t *kv_elts;
  332. kv_elts = scm_u32vector_elements (kv, &kv_handle, &kv_len, &kv_inc);
  333. for (i = 0; i < kv_len; i++, kv_elts += kv_inc)
  334. {
  335. SCM elt = scm_array_handle_ref (&v_handle, (*kv_elts)*v_inc);
  336. if ((bit && scm_is_true (elt)) || (!bit && scm_is_false (elt)))
  337. count++;
  338. }
  339. scm_array_handle_release (&kv_handle);
  340. }
  341. else
  342. scm_wrong_type_arg_msg (NULL, 0, kv, "bitvector or u32vector");
  343. scm_array_handle_release (&v_handle);
  344. }
  345. return scm_from_size_t (count);
  346. }
  347. #undef FUNC_NAME
  348. SCM_DEFINE (scm_bit_position, "bit-position", 3, 0, 0,
  349. (SCM item, SCM v, SCM k),
  350. "Return the index of the first occurrence of @var{item} in bit\n"
  351. "vector @var{v}, starting from @var{k}. If there is no\n"
  352. "@var{item} entry between @var{k} and the end of\n"
  353. "@var{v}, then return @code{#f}. For example,\n"
  354. "\n"
  355. "@example\n"
  356. "(bit-position #t #*000101 0) @result{} 3\n"
  357. "(bit-position #f #*0001111 3) @result{} #f\n"
  358. "@end example")
  359. #define FUNC_NAME s_scm_bit_position
  360. {
  361. scm_c_issue_deprecation_warning
  362. ("bit-position is deprecated. Use bitvector-position, or "
  363. "array-ref in a loop if you need generic arrays instead.");
  364. if (scm_is_bitvector (v))
  365. return scm_bitvector_position (v, item, k);
  366. scm_t_array_handle handle;
  367. size_t off, len;
  368. ssize_t inc;
  369. scm_bitvector_elements (v, &handle, &off, &len, &inc);
  370. int bit = scm_to_bool (item);
  371. size_t first_bit = scm_to_unsigned_integer (k, 0, len);
  372. SCM res = SCM_BOOL_F;
  373. for (size_t i = first_bit; i < len; i++)
  374. {
  375. SCM elt = scm_array_handle_ref (&handle, i*inc);
  376. if ((bit && scm_is_true (elt)) || (!bit && scm_is_false (elt)))
  377. {
  378. res = scm_from_size_t (i);
  379. break;
  380. }
  381. }
  382. scm_array_handle_release (&handle);
  383. return res;
  384. }
  385. #undef FUNC_NAME
  386. SCM_DEFINE (scm_bit_set_star_x, "bit-set*!", 3, 0, 0,
  387. (SCM v, SCM kv, SCM obj),
  388. "Set entries of bit vector @var{v} to @var{obj}, with @var{kv}\n"
  389. "selecting the entries to change. The return value is\n"
  390. "unspecified.\n"
  391. "\n"
  392. "If @var{kv} is a bit vector, then those entries where it has\n"
  393. "@code{#t} are the ones in @var{v} which are set to @var{obj}.\n"
  394. "@var{v} must be at least as long as @var{kv}. When @var{obj}\n"
  395. "is @code{#t} it's like @var{kv} is OR'ed into @var{v}. Or when\n"
  396. "@var{obj} is @code{#f} it can be seen as an ANDNOT.\n"
  397. "\n"
  398. "@example\n"
  399. "(define bv #*01000010)\n"
  400. "(bit-set*! bv #*10010001 #t)\n"
  401. "bv\n"
  402. "@result{} #*11010011\n"
  403. "@end example\n"
  404. "\n"
  405. "If @var{kv} is a u32vector, then its elements are\n"
  406. "indices into @var{v} which are set to @var{obj}.\n"
  407. "\n"
  408. "@example\n"
  409. "(define bv #*01000010)\n"
  410. "(bit-set*! bv #u32(5 2 7) #t)\n"
  411. "bv\n"
  412. "@result{} #*01100111\n"
  413. "@end example")
  414. #define FUNC_NAME s_scm_bit_set_star_x
  415. {
  416. scm_c_issue_deprecation_warning
  417. ("bit-set*! is deprecated. Use bitvector-set-bits! or "
  418. "bitvector-clear-bits! on bitvectors, or array-set! in a loop "
  419. "if you need to work on generic arrays.");
  420. int bit = scm_to_bool (obj);
  421. if (scm_is_bitvector (v) && scm_is_bitvector (kv))
  422. {
  423. if (bit)
  424. scm_c_bitvector_set_bits_x (v, kv);
  425. else
  426. scm_c_bitvector_clear_bits_x (v, kv);
  427. return SCM_UNSPECIFIED;
  428. }
  429. scm_t_array_handle v_handle;
  430. size_t v_off, v_len;
  431. ssize_t v_inc;
  432. scm_bitvector_writable_elements (v, &v_handle, &v_off, &v_len, &v_inc);
  433. if (scm_is_bitvector (kv))
  434. {
  435. size_t kv_len = scm_c_bitvector_length (kv);
  436. if (v_len < kv_len)
  437. scm_misc_error (NULL,
  438. "selection bitvector longer than target bitvector",
  439. SCM_EOL);
  440. for (size_t i = 0; i < kv_len; i++)
  441. if (scm_is_true (scm_c_bitvector_ref (kv, i)))
  442. scm_array_handle_set (&v_handle, i*v_inc, obj);
  443. }
  444. else if (scm_is_true (scm_u32vector_p (kv)))
  445. {
  446. scm_t_array_handle kv_handle;
  447. size_t kv_len;
  448. ssize_t kv_inc;
  449. const uint32_t *kv_elts;
  450. kv_elts = scm_u32vector_elements (kv, &kv_handle, &kv_len, &kv_inc);
  451. for (size_t i = 0; i < kv_len; i++, kv_elts += kv_inc)
  452. scm_array_handle_set (&v_handle, (*kv_elts)*v_inc, obj);
  453. scm_array_handle_release (&kv_handle);
  454. }
  455. else
  456. scm_wrong_type_arg_msg (NULL, 0, kv, "bitvector or u32vector");
  457. scm_array_handle_release (&v_handle);
  458. return SCM_UNSPECIFIED;
  459. }
  460. #undef FUNC_NAME
  461. SCM
  462. scm_istr2bve (SCM str)
  463. {
  464. scm_t_array_handle handle;
  465. size_t len = scm_i_string_length (str);
  466. SCM vec = scm_c_make_bitvector (len, SCM_UNDEFINED);
  467. SCM res = vec;
  468. uint32_t mask;
  469. size_t k, j;
  470. const char *c_str;
  471. uint32_t *data;
  472. scm_c_issue_deprecation_warning
  473. ("scm_istr2bve is deprecated. "
  474. "Read from a string instead, prefixed with `#*'.");
  475. data = scm_bitvector_writable_elements (vec, &handle, NULL, NULL, NULL);
  476. c_str = scm_i_string_chars (str);
  477. for (k = 0; k < (len + 31) / 32; k++)
  478. {
  479. data[k] = 0L;
  480. j = len - k * 32;
  481. if (j > 32)
  482. j = 32;
  483. for (mask = 1L; j--; mask <<= 1)
  484. switch (*c_str++)
  485. {
  486. case '0':
  487. break;
  488. case '1':
  489. data[k] |= mask;
  490. break;
  491. default:
  492. res = SCM_BOOL_F;
  493. goto exit;
  494. }
  495. }
  496. exit:
  497. scm_array_handle_release (&handle);
  498. scm_remember_upto_here_1 (str);
  499. return res;
  500. }
  501. SCM
  502. scm_from_contiguous_typed_array (SCM type, SCM bounds, const void *bytes,
  503. size_t byte_len)
  504. #define FUNC_NAME "scm_from_contiguous_typed_array"
  505. {
  506. size_t k, rlen = 1;
  507. scm_t_array_dim *s;
  508. SCM ra;
  509. scm_t_array_handle h;
  510. void *elts;
  511. size_t sz;
  512. scm_c_issue_deprecation_warning
  513. ("scm_from_contiguous_typed_array is deprecated. "
  514. "Instead, use scm_make_typed_array() and the array handle functions "
  515. "to copy data to the new array.");
  516. ra = scm_i_shap2ra (bounds);
  517. s = SCM_I_ARRAY_DIMS (ra);
  518. k = SCM_I_ARRAY_NDIM (ra);
  519. while (k--)
  520. {
  521. s[k].inc = rlen;
  522. SCM_ASSERT_RANGE (1, bounds, s[k].lbnd <= s[k].ubnd + 1);
  523. rlen = (s[k].ubnd - s[k].lbnd + 1) * s[k].inc;
  524. }
  525. SCM_I_ARRAY_SET_V (ra, scm_make_generalized_vector (type, scm_from_size_t (rlen), SCM_UNDEFINED));
  526. scm_array_get_handle (ra, &h);
  527. elts = h.writable_elements;
  528. sz = scm_array_handle_uniform_element_bit_size (&h);
  529. scm_array_handle_release (&h);
  530. if (sz >= 8 && ((sz % 8) == 0))
  531. {
  532. if (byte_len % (sz / 8))
  533. SCM_MISC_ERROR ("byte length not a multiple of the unit size", SCM_EOL);
  534. if (byte_len / (sz / 8) != rlen)
  535. SCM_MISC_ERROR ("byte length and dimensions do not match", SCM_EOL);
  536. }
  537. else if (sz < 8)
  538. {
  539. /* Elements of sub-byte size (bitvectors) are addressed in 32-bit
  540. units. */
  541. if (byte_len != ((rlen * sz + 31) / 32) * 4)
  542. SCM_MISC_ERROR ("byte length and dimensions do not match", SCM_EOL);
  543. }
  544. else
  545. /* an internal guile error, really */
  546. SCM_MISC_ERROR ("uniform elements larger than 8 bits must fill whole bytes", SCM_EOL);
  547. memcpy (elts, bytes, byte_len);
  548. if (1 == SCM_I_ARRAY_NDIM (ra) && 0 == SCM_I_ARRAY_BASE (ra))
  549. if (0 == s->lbnd)
  550. return SCM_I_ARRAY_V (ra);
  551. return ra;
  552. }
  553. #undef FUNC_NAME
  554. SCM_GLOBAL_SYMBOL (scm_sym_copy, "copy");
  555. SCM
  556. scm_make_srcprops (long line, int col, SCM filename, SCM copy, SCM alist)
  557. {
  558. scm_c_issue_deprecation_warning
  559. ("scm_make_srcprops is deprecated; use set-source-properties! instead");
  560. alist = SCM_UNBNDP (copy) ? alist : scm_acons (scm_sym_copy, copy, alist);
  561. return scm_i_make_srcprops (scm_from_long (line), scm_from_int (col),
  562. filename, alist);
  563. }
  564. SCM
  565. scm_copy_tree (SCM obj)
  566. {
  567. scm_c_issue_deprecation_warning
  568. ("scm_copy_tree is deprecated; use copy-tree from (ice-9 copy-tree) "
  569. "instead.");
  570. return scm_call_1 (scm_c_public_ref ("ice-9 copy-tree", "copy-tree"), obj);
  571. }
  572. SCM_DEFINE (scm_dynamic_unlink, "dynamic-unlink", 1, 0, 0, (SCM obj), "")
  573. #define FUNC_NAME s_scm_dynamic_unlink
  574. {
  575. scm_c_issue_deprecation_warning
  576. ("scm_dynamic_unlink has no effect and is deprecated. Unloading "
  577. "shared libraries is no longer supported.");
  578. return SCM_UNSPECIFIED;
  579. }
  580. #undef FUNC_NAME
  581. void
  582. scm_i_init_deprecated ()
  583. {
  584. #include "deprecated.x"
  585. }
  586. #endif /* SCM_ENABLE_DEPRECATD == 1 */