Title: [284208] trunk/Source/bmalloc
- Revision
- 284208
- Author
- [email protected]
- Date
- 2021-10-14 15:52:31 -0700 (Thu, 14 Oct 2021)
Log Message
[libpas] Use `enum { ... }` instead of `static const size_t` for constant values used for array size
https://bugs.webkit.org/show_bug.cgi?id=231778
Reviewed by Chris Dumez.
Since libpas is written in C (not C++), we cannot use `static const size_t` value for array's size.
In C, it is not usable as a constant _expression_ for array size. Use `enum` hack instead.
* libpas/src/libpas/pas_generic_large_free_heap.h:
(pas_generic_large_free_heap_try_allocate):
* libpas/src/libpas/pas_large_sharing_pool.c:
(pas_large_sharing_pool_allocate_and_commit):
* libpas/src/libpas/pas_segregated_view_allocator_inlines.h:
(pas_segregated_view_will_start_allocating):
* libpas/src/libpas/pas_simple_large_free_heap.c:
(merge):
Modified Paths
Diff
Modified: trunk/Source/bmalloc/ChangeLog (284207 => 284208)
--- trunk/Source/bmalloc/ChangeLog 2021-10-14 22:50:23 UTC (rev 284207)
+++ trunk/Source/bmalloc/ChangeLog 2021-10-14 22:52:31 UTC (rev 284208)
@@ -1,3 +1,22 @@
+2021-10-14 Yusuke Suzuki <[email protected]>
+
+ [libpas] Use `enum { ... }` instead of `static const size_t` for constant values used for array size
+ https://bugs.webkit.org/show_bug.cgi?id=231778
+
+ Reviewed by Chris Dumez.
+
+ Since libpas is written in C (not C++), we cannot use `static const size_t` value for array's size.
+ In C, it is not usable as a constant _expression_ for array size. Use `enum` hack instead.
+
+ * libpas/src/libpas/pas_generic_large_free_heap.h:
+ (pas_generic_large_free_heap_try_allocate):
+ * libpas/src/libpas/pas_large_sharing_pool.c:
+ (pas_large_sharing_pool_allocate_and_commit):
+ * libpas/src/libpas/pas_segregated_view_allocator_inlines.h:
+ (pas_segregated_view_will_start_allocating):
+ * libpas/src/libpas/pas_simple_large_free_heap.c:
+ (merge):
+
2021-10-14 Myles C. Maxfield <[email protected]>
All the SDKVariant.xcconfig files should match
Modified: trunk/Source/bmalloc/libpas/src/libpas/pas_generic_large_free_heap.h (284207 => 284208)
--- trunk/Source/bmalloc/libpas/src/libpas/pas_generic_large_free_heap.h 2021-10-14 22:50:23 UTC (rev 284207)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_generic_large_free_heap.h 2021-10-14 22:52:31 UTC (rev 284208)
@@ -387,7 +387,7 @@
}
}
} else {
- static const size_t max_num_additions = 2;
+ enum { max_num_additions = 2 };
pas_large_free additions[max_num_additions];
size_t num_additions = 0;
Modified: trunk/Source/bmalloc/libpas/src/libpas/pas_heap_config_kind.h (284207 => 284208)
--- trunk/Source/bmalloc/libpas/src/libpas/pas_heap_config_kind.h 2021-10-14 22:50:23 UTC (rev 284207)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_heap_config_kind.h 2021-10-14 22:52:31 UTC (rev 284208)
@@ -42,13 +42,13 @@
typedef enum pas_heap_config_kind pas_heap_config_kind;
-static const unsigned pas_heap_config_kind_num_kinds =
+enum { pas_heap_config_kind_num_kinds =
0
#define PAS_DEFINE_HEAP_CONFIG_KIND(name, value) \
+ 1
#include "pas_heap_config_kind.def"
#undef PAS_DEFINE_HEAP_CONFIG_KIND
- ;
+};
static inline const char*
pas_heap_config_kind_get_string(pas_heap_config_kind kind)
Modified: trunk/Source/bmalloc/libpas/src/libpas/pas_large_sharing_pool.c (284207 => 284208)
--- trunk/Source/bmalloc/libpas/src/libpas/pas_large_sharing_pool.c 2021-10-14 22:50:23 UTC (rev 284207)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_large_sharing_pool.c 2021-10-14 22:52:31 UTC (rev 284208)
@@ -1068,7 +1068,7 @@
case pas_physical_memory_is_locked_by_virtual_range_common_lock:
if (commit_log.total || pas_physical_page_sharing_pool_balance < 0) {
- static const size_t max_num_locks_held = 2;
+ enum { max_num_locks_held = 2 };
pas_lock* locks_held[max_num_locks_held];
size_t num_locks_held;
Modified: trunk/Source/bmalloc/libpas/src/libpas/pas_segregated_view_allocator_inlines.h (284207 => 284208)
--- trunk/Source/bmalloc/libpas/src/libpas/pas_segregated_view_allocator_inlines.h 2021-10-14 22:50:23 UTC (rev 284207)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_segregated_view_allocator_inlines.h 2021-10-14 22:52:31 UTC (rev 284208)
@@ -140,7 +140,7 @@
return NULL;
}
} else {
- static const size_t max_num_locks_held = 1;
+ enum { max_num_locks_held = 1 };
pas_lock* locks_held[max_num_locks_held];
size_t num_locks_held;
bool did_lock_lock;
Modified: trunk/Source/bmalloc/libpas/src/libpas/pas_simple_large_free_heap.c (284207 => 284208)
--- trunk/Source/bmalloc/libpas/src/libpas/pas_simple_large_free_heap.c 2021-10-14 22:50:23 UTC (rev 284207)
+++ trunk/Source/bmalloc/libpas/src/libpas/pas_simple_large_free_heap.c 2021-10-14 22:52:31 UTC (rev 284208)
@@ -136,7 +136,7 @@
static void merge(pas_simple_large_free_heap* heap, pas_large_free new_free,
pas_large_free_heap_config* config)
{
- static const size_t max_num_victims = 2;
+ enum { max_num_victims = 2 };
size_t victim_indices[max_num_victims];
size_t num_victims = 0;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes