0003-mksquashfs.c-get-inline-functions-work-with-C99.patch 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. From ac6268e843c43286eebff2a1052182c2393cdb2e Mon Sep 17 00:00:00 2001
  2. From: Roy Li <rongqing.li@windriver.com>
  3. Date: Mon, 14 Sep 2015 12:31:42 +0800
  4. Subject: [PATCH] mksquashfs.c: get inline functions work with both gnu11 and gnu89
  5. Upstream-Status: Pending
  6. After gcc upgraded to gcc5, and if the codes is compiled without optimization(-O0),
  7. and the below error will happen:
  8. | mksquashfs.o: In function `create_inode':
  9. | git/squashfs-tools/mksquashfs.c:897: undefined reference to `get_inode_no'
  10. | git/squashfs-tools/mksquashfs.c:960: undefined reference to `get_parent_no'
  11. | git/squashfs-tools/mksquashfs.c:983: undefined reference to `get_parent_no'
  12. | mksquashfs.o: In function `reader_read_process':
  13. | git/squashfs-tools/mksquashfs.c:2132: undefined reference to `is_fragment'
  14. | mksquashfs.o: In function `reader_read_file':
  15. | git/squashfs-tools/mksquashfs.c:2228: undefined reference to `is_fragment'
  16. | mksquashfs.o: In function `dir_scan':
  17. | git/squashfs-tools/mksquashfs.c:3101: undefined reference to `create_dir_entry'
  18. gcc5 defaults to -std=gnu11 instead of -std=gnu89, and it requires that exactly one C
  19. source file has the callable copy of the inline function. Consider the following
  20. program:
  21. inline int
  22. foo (void)
  23. {
  24. return 42;
  25. }
  26. int
  27. main (void)
  28. {
  29. return foo ();
  30. }
  31. The program above will not link with the C99 inline semantics, because no out-of-line
  32. function foo is generated. To fix this, either mark the function foo as static, or
  33. add the following declaration:
  34. static inline int foo (void);
  35. more information refer to: https://gcc.gnu.org/gcc-5/porting_to.html;
  36. but the use of "extern inline" will lead to the compilation issue if gcc is not
  37. gcc5, as the commit in oe-core d0af30c92fde [alsa-lib: Change function type to
  38. "static __inline__"]
  39. "extern __inline__ function()" is the inlined version that
  40. can be used in this compilation unit, but there will be another
  41. definition of this function somewhere, so compiler will not emit
  42. any code for the function body. This causes problem in -O0,
  43. where functions are never inlined, the function call is preserved,
  44. but linker can't find the symbol, thus the error happens.
  45. so replace "inline" with "static inline" to make it work with both gnu11 and gnu89
  46. Signed-off-by: Roy Li <rongqing.li@windriver.com>
  47. ---
  48. squashfs-tools/mksquashfs.c | 20 ++++++++++----------
  49. 1 file changed, 10 insertions(+), 10 deletions(-)
  50. diff --git a/squashfs-tools/mksquashfs.c b/squashfs-tools/mksquashfs.c
  51. index d221c35..6bba1d2 100644
  52. --- a/squashfs-tools/mksquashfs.c
  53. +++ b/squashfs-tools/mksquashfs.c
  54. @@ -828,13 +828,13 @@ char *subpathname(struct dir_ent *dir_ent)
  55. }
  56. -inline unsigned int get_inode_no(struct inode_info *inode)
  57. +static inline unsigned int get_inode_no(struct inode_info *inode)
  58. {
  59. return inode->inode_number;
  60. }
  61. -inline unsigned int get_parent_no(struct dir_info *dir)
  62. +static inline unsigned int get_parent_no(struct dir_info *dir)
  63. {
  64. return dir->depth ? get_inode_no(dir->dir_ent->inode) : inode_no;
  65. }
  66. @@ -2027,7 +2027,7 @@ struct file_info *duplicate(long long file_size, long long bytes,
  67. }
  68. -inline int is_fragment(struct inode_info *inode)
  69. +static inline int is_fragment(struct inode_info *inode)
  70. {
  71. off_t file_size = inode->buf.st_size;
  72. @@ -2996,13 +2996,13 @@ struct inode_info *lookup_inode2(struct stat *buf, int pseudo, int id)
  73. }
  74. -inline struct inode_info *lookup_inode(struct stat *buf)
  75. +static inline struct inode_info *lookup_inode(struct stat *buf)
  76. {
  77. return lookup_inode2(buf, 0, 0);
  78. }
  79. -inline void alloc_inode_no(struct inode_info *inode, unsigned int use_this)
  80. +static inline void alloc_inode_no(struct inode_info *inode, unsigned int use_this)
  81. {
  82. if (inode->inode_number == 0) {
  83. inode->inode_number = use_this ? : inode_no ++;
  84. @@ -3013,7 +3013,7 @@ inline void alloc_inode_no(struct inode_info *inode, unsigned int use_this)
  85. }
  86. -inline struct dir_ent *create_dir_entry(char *name, char *source_name,
  87. +static inline struct dir_ent *create_dir_entry(char *name, char *source_name,
  88. char *nonstandard_pathname, struct dir_info *dir)
  89. {
  90. struct dir_ent *dir_ent = malloc(sizeof(struct dir_ent));
  91. @@ -3031,7 +3031,7 @@ inline struct dir_ent *create_dir_entry(char *name, char *source_name,
  92. }
  93. -inline void add_dir_entry(struct dir_ent *dir_ent, struct dir_info *sub_dir,
  94. +static inline void add_dir_entry(struct dir_ent *dir_ent, struct dir_info *sub_dir,
  95. struct inode_info *inode_info)
  96. {
  97. struct dir_info *dir = dir_ent->our_dir;
  98. @@ -3047,7 +3047,7 @@ inline void add_dir_entry(struct dir_ent *dir_ent, struct dir_info *sub_dir,
  99. }
  100. -inline void add_dir_entry2(char *name, char *source_name,
  101. +static inline void add_dir_entry2(char *name, char *source_name,
  102. char *nonstandard_pathname, struct dir_info *sub_dir,
  103. struct inode_info *inode_info, struct dir_info *dir)
  104. {
  105. @@ -3059,7 +3059,7 @@ inline void add_dir_entry2(char *name, char *source_name,
  106. }
  107. -inline void free_dir_entry(struct dir_ent *dir_ent)
  108. +static inline void free_dir_entry(struct dir_ent *dir_ent)
  109. {
  110. if(dir_ent->name)
  111. free(dir_ent->name);
  112. @@ -3080,7 +3080,7 @@ inline void free_dir_entry(struct dir_ent *dir_ent)
  113. }
  114. -inline void add_excluded(struct dir_info *dir)
  115. +static inline void add_excluded(struct dir_info *dir)
  116. {
  117. dir->excluded ++;
  118. }
  119. --
  120. 1.9.1