When the list of functions is empty, no need to create the array (it is actually an error for some compilers).

This commit is contained in:
Juan Jose Garcia Ripoll 2008-10-25 01:17:15 +02:00
parent 75297eba4e
commit c57459a6ad

View file

@ -196,8 +196,13 @@
(wt-nl-h "#else")
(wt-nl-h "static cl_object VV[VM];")
(wt-nl-h "#endif"))))
(wt-nl-h "#define compiler_cfuns_size " (length *global-cfuns-array*))
(wt-nl-h "static const struct ecl_cfun compiler_cfuns[" (length *global-cfuns-array*) "];")
(let ((n-cfuns (length *global-cfuns-array*)))
(wt-nl-h "#define compiler_cfuns_size " n-cfuns)
(if (zerop n-cfuns)
(wt-nl-h "#define compiler_cfuns NULL")
(wt-nl-h "static const struct ecl_cfun compiler_cfuns[" n-cfuns "];")))
(dolist (l *linking-calls*)
(let* ((c-name (fourth l))
(var-name (fifth l)))
@ -697,7 +702,8 @@
(close-inline-blocks)))
(defun output-cfuns (stream)
(format stream "~%static const struct ecl_cfun compiler_cfuns[] = {~
(format stream "~%#ifndef compiler_cfuns~
~%static const struct ecl_cfun compiler_cfuns[] = {~
~%~t/*t,m,narg,padding,name,entry,block*/");
(loop for (loc fname-loc fun) in (nreverse *global-cfuns-array*)
do (let* ((cfun (fun-cfun fun))
@ -706,7 +712,7 @@
(narg (if (= minarg maxarg) maxarg nil)))
(format stream "~%{0,0,~D,0,MAKE_FIXNUM(~D),(cl_objectfn)~A,MAKE_FIXNUM(~D)},"
(or narg -1) (second loc) cfun (second fname-loc))))
(format stream "~%};"))
(format stream "~%};~%#endif"))
;;; ----------------------------------------------------------------------