diff --git a/glfw/backend_utils.c b/glfw/backend_utils.c index a2651c3d6..54065d30b 100644 --- a/glfw/backend_utils.c +++ b/glfw/backend_utils.c @@ -91,7 +91,7 @@ compare_timers(const void *a_, const void *b_) { return (a->trigger_at > b->trigger_at) ? 1 : (a->trigger_at < b->trigger_at) ? -1 : 0; } -static inline void +static void update_timers(EventLoopData *eld) { if (eld->timers_count > 1) qsort(eld->timers, eld->timers_count, sizeof(eld->timers[0]), compare_timers); } @@ -164,7 +164,7 @@ prepareForPoll(EventLoopData *eld, monotonic_t timeout) { return timeout; } -static inline struct timespec +static struct timespec calc_time(monotonic_t nsec) { struct timespec result; result.tv_sec = nsec / (1000LL * 1000LL * 1000LL); @@ -271,7 +271,7 @@ wakeupEventLoop(EventLoopData *eld) { } #ifndef HAS_EVENT_FD -static inline void +static void closeFds(int *fds, size_t count) { while(count--) { if (*fds > 0) { diff --git a/glfw/cocoa_init.m b/glfw/cocoa_init.m index 1fc7a0aa3..a43aa24e6 100644 --- a/glfw/cocoa_init.m +++ b/glfw/cocoa_init.m @@ -453,7 +453,7 @@ void* _glfwLoadLocalVulkanLoaderNS(void) ////// GLFW platform API ////// ////////////////////////////////////////////////////////////////////////// -static inline bool +static bool is_ctrl_tab(NSEvent *event, NSEventModifierFlags modifierFlags) { if ( (modifierFlags == NSEventModifierFlagControl && @@ -464,7 +464,7 @@ is_ctrl_tab(NSEvent *event, NSEventModifierFlags modifierFlags) { return false; } -static inline bool +static bool is_cmd_period(NSEvent *event, NSEventModifierFlags modifierFlags) { if (modifierFlags != NSEventModifierFlagCommand) return false; if ([event.charactersIgnoringModifiers isEqualToString:@"."]) return true; @@ -703,7 +703,7 @@ typedef struct { static Timer timers[128] = {{0}}; static size_t num_timers = 0; -static inline void +static void remove_timer_at(size_t idx) { if (idx < num_timers) { Timer *t = timers + idx; diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index 4a7c87191..f7e37c653 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -233,10 +233,10 @@ mac_ucode_to_functional(uint32_t key_code) { // {{{ } } // }}} -static inline bool +static bool is_surrogate(UniChar uc) { return (uc - 0xd800u) < 2048u; } -static inline uint32_t +static uint32_t get_first_codepoint(UniChar *utf16, UniCharCount num) { if (!num) return 0; if (!is_surrogate(*utf16)) return *utf16; @@ -244,7 +244,7 @@ get_first_codepoint(UniChar *utf16, UniCharCount num) { return 0; } -static inline bool +static bool is_pua_char(uint32_t ch) { return (0xE000 <= ch && ch <= 0xF8FF) || (0xF0000 <= ch && ch <= 0xFFFFF) || (0x100000 <= ch && ch <= 0x10FFFF); } @@ -321,7 +321,7 @@ _glfwShutdownCVDisplayLink(unsigned long long timer_id UNUSED, void *user_data U } } -static inline void +static void requestRenderFrame(_GLFWwindow *w, GLFWcocoarenderframefun callback) { if (!callback) { w->ns.renderFrameRequested = false; @@ -505,7 +505,7 @@ translateFlags(NSUInteger flags) #define debug_key(...) if (_glfw.hints.init.debugKeyboard) { fprintf(stderr, __VA_ARGS__); fflush(stderr); } -static inline const char* +static const char* format_mods(int mods) { static char buf[128]; char *p = buf, *s; @@ -525,7 +525,7 @@ format_mods(int mods) { return buf; } -static inline const char* +static const char* format_text(const char *src) { static char buf[256]; char *p = buf; @@ -1144,7 +1144,7 @@ static const NSRange kEmptyRange = { NSNotFound, 0 }; [super updateTrackingAreas]; } -static inline UInt32 +static UInt32 convert_cocoa_to_carbon_modifiers(NSUInteger flags) { UInt32 mods = 0; if (flags & NSEventModifierFlagShift) @@ -1161,7 +1161,7 @@ convert_cocoa_to_carbon_modifiers(NSUInteger flags) { return (mods >> 8) & 0xFF; } -static inline void +static void convert_utf16_to_utf8(UniChar *src, UniCharCount src_length, char *dest, size_t dest_sz) { CFStringRef string = CFStringCreateWithCharactersNoCopy(kCFAllocatorDefault, src, @@ -1174,12 +1174,12 @@ convert_utf16_to_utf8(UniChar *src, UniCharCount src_length, char *dest, size_t CFRelease(string); } -static inline bool +static bool alternate_key_is_ok(uint32_t key, uint32_t akey) { return akey > 31 && akey != key && !is_pua_char(akey); } -static inline void +static void add_alternate_keys(GLFWkeyevent *ev, NSEvent *event) { ev->alternate_key = translateKey(ev->native_key, false); if (!alternate_key_is_ok(ev->key, ev->alternate_key)) ev->alternate_key = 0; @@ -1198,7 +1198,7 @@ add_alternate_keys(GLFWkeyevent *ev, NSEvent *event) { } } -static inline bool +static bool is_ascii_control_char(char x) { return x == 0 || (1 <= x && x <= 31) || x == 127; } diff --git a/glfw/dbus_glfw.c b/glfw/dbus_glfw.c index 5213800b8..fb5297273 100644 --- a/glfw/dbus_glfw.c +++ b/glfw/dbus_glfw.c @@ -31,7 +31,7 @@ #include #include -static inline void +static void report_error(DBusError *err, const char *fmt, ...) { static char buf[1024]; va_list args; @@ -64,7 +64,7 @@ on_dbus_watch_ready(int fd UNUSED, int events, void *data) { dbus_watch_handle(watch, flags); } -static inline int +static int events_for_watch(DBusWatch *watch) { int events = 0; unsigned int flags = dbus_watch_get_flags(watch); diff --git a/glfw/ibus_glfw.c b/glfw/ibus_glfw.c index ead564b8f..ff90beb94 100644 --- a/glfw/ibus_glfw.c +++ b/glfw/ibus_glfw.c @@ -50,13 +50,13 @@ enum Capabilities { }; -static inline bool +static bool test_env_var(const char *name, const char *val) { const char *q = getenv(name); return (q && strcmp(q, val) == 0) ? true : false; } -static inline size_t +static size_t GLFW_MIN(size_t a, size_t b) { return a < b ? a : b; } @@ -106,7 +106,7 @@ get_ibus_text_from_message(DBusMessage *msg) { return text; } -static inline void +static void send_text(const char *text, GLFWIMEState ime_state) { _GLFWwindow *w = _glfwFocusedWindow(); if (w && w->callbacks.keyboard) { @@ -147,7 +147,7 @@ message_handler(DBusConnection *conn UNUSED, DBusMessage *msg, void *user_data) return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } -static inline const char* +static const char* get_ibus_address_file_name(void) { const char *addr; static char ans[PATH_MAX]; @@ -196,7 +196,7 @@ get_ibus_address_file_name(void) { } -static inline bool +static bool read_ibus_address(_GLFWIBUSData *ibus) { static char buf[1024]; struct stat s; @@ -379,7 +379,7 @@ typedef enum } IBusModifierType; -static inline uint32_t +static uint32_t ibus_key_state(unsigned int glfw_modifiers, int action) { uint32_t ans = action == GLFW_RELEASE ? IBUS_RELEASE_MASK : 0; #define M(g, i) if(glfw_modifiers & GLFW_MOD_##g) ans |= i diff --git a/glfw/wl_init.c b/glfw/wl_init.c index 2c33a07bf..d5c997630 100644 --- a/glfw/wl_init.c +++ b/glfw/wl_init.c @@ -54,7 +54,7 @@ #endif -static inline int min(int n1, int n2) +static int min(int n1, int n2) { return n1 < n2 ? n1 : n2; } diff --git a/glfw/wl_text_input.c b/glfw/wl_text_input.c index dd0d7e0d5..4afc4a3d0 100644 --- a/glfw/wl_text_input.c +++ b/glfw/wl_text_input.c @@ -43,7 +43,7 @@ text_input_leave(void *data UNUSED, struct zwp_text_input_v3 *text_input UNUSED, } } -static inline void +static void send_text(const char *text, GLFWIMEState ime_state) { _GLFWwindow *w = _glfwFocusedWindow(); if (w && w->callbacks.keyboard) { diff --git a/glfw/wl_window.c b/glfw/wl_window.c index f982cc38f..d8ce80498 100644 --- a/glfw/wl_window.c +++ b/glfw/wl_window.c @@ -1762,7 +1762,7 @@ void _glfwSetupWaylandPrimarySelectionDevice() { if (_glfw.wl.primarySelectionDevice) zwp_primary_selection_device_v1_add_listener(_glfw.wl.primarySelectionDevice, &primary_selection_device_listener, NULL); } -static inline bool _glfwEnsureDataDevice(void) { +static bool _glfwEnsureDataDevice(void) { if (!_glfw.wl.dataDeviceManager) { _glfwInputError(GLFW_PLATFORM_ERROR, diff --git a/glfw/x11_window.c b/glfw/x11_window.c index 9f80bb670..bb46ea63f 100644 --- a/glfw/x11_window.c +++ b/glfw/x11_window.c @@ -281,7 +281,7 @@ updateNormalHints(_GLFWwindow* window, int width, int height) XFree(hints); } -static inline bool +static bool is_window_fullscreen(_GLFWwindow* window) { Atom* states; @@ -310,7 +310,7 @@ is_window_fullscreen(_GLFWwindow* window) return ans; } -static inline void +static void set_fullscreen(_GLFWwindow *window, bool on) { if (_glfw.x11.NET_WM_STATE && _glfw.x11.NET_WM_STATE_FULLSCREEN) { sendEventToWM(window, @@ -2646,7 +2646,7 @@ void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity) PropModeReplace, (unsigned char*) &value, 1); } -static inline unsigned +static unsigned dispatch_x11_queued_events(int num_events) { unsigned dispatched = num_events > 0 ? num_events : 0; while (num_events-- > 0) { diff --git a/glfw/xkb_glfw.c b/glfw/xkb_glfw.c index c0fcb7daf..d212b909b 100644 --- a/glfw/xkb_glfw.c +++ b/glfw/xkb_glfw.c @@ -490,7 +490,7 @@ load_compose_tables(_GLFWXKBData *xkb) { xkb_compose_table_unref(compose_table); } -static inline xkb_mod_mask_t +static xkb_mod_mask_t active_unknown_modifiers(_GLFWXKBData *xkb, struct xkb_state *state) { size_t i = 0; xkb_mod_mask_t ans = 0; @@ -577,7 +577,7 @@ glfw_xkb_should_repeat(_GLFWXKBData *xkb, xkb_keycode_t keycode) { } -static inline xkb_keysym_t +static xkb_keysym_t compose_symbol(struct xkb_compose_state *composeState, xkb_keysym_t sym, int *compose_completed, char *key_text, int n) { *compose_completed = 0; if (sym == XKB_KEY_NoSymbol || !composeState) return sym; @@ -610,7 +610,7 @@ glfw_xkb_keysym_from_name(const char *name, bool case_sensitive) { return (int)xkb_keysym_from_name(name, case_sensitive ? XKB_KEYSYM_NO_FLAGS : XKB_KEYSYM_CASE_INSENSITIVE); } -static inline const char* +static const char* format_mods(unsigned int mods) { static char buf[128]; char *p = buf, *s; @@ -632,7 +632,7 @@ format_mods(unsigned int mods) { return buf; } -static inline const char* +static const char* format_xkb_mods(_GLFWXKBData *xkb, const char* name, xkb_mod_mask_t mods) { static char buf[512]; char *p = buf, *s; diff --git a/kittens/choose/output.c b/kittens/choose/output.c index e82679af6..a669baae7 100644 --- a/kittens/choose/output.c +++ b/kittens/choose/output.c @@ -14,7 +14,7 @@ #ifdef ISWINDOWS #include #define STDOUT_FILENO 1 -static inline ssize_t ms_write(int fd, const void* buf, size_t count) { return _write(fd, buf, (unsigned int)count); } +static ssize_t ms_write(int fd, const void* buf, size_t count) { return _write(fd, buf, (unsigned int)count); } #define write ms_write #else #include @@ -24,7 +24,7 @@ static inline ssize_t ms_write(int fd, const void* buf, size_t count) { return _ #define FIELD(x, which) (((Candidate*)(x))->which) -static inline bool +static bool ensure_space(GlobalData *global, size_t sz) { if (global->output_sz < sz + global->output_pos || !global->output) { size_t before = global->output_sz; @@ -38,7 +38,7 @@ ensure_space(GlobalData *global, size_t sz) { return true; } -static inline void +static void output_text(GlobalData *global, const text_t *data, size_t sz) { if (ensure_space(global, sz)) { memcpy(global->output + global->output_pos, data, sizeof(text_t) * sz); diff --git a/kittens/choose/score.c b/kittens/choose/score.c index 5c4cf6af1..fa48efd80 100644 --- a/kittens/choose/score.c +++ b/kittens/choose/score.c @@ -59,7 +59,7 @@ free_workspace(void *v) { return NULL; } -static inline bool +static bool has_char(text_t *text, len_t sz, text_t ch) { for(len_t i = 0; i < sz; i++) { if(text[i] == ch) return true; @@ -67,7 +67,7 @@ has_char(text_t *text, len_t sz, text_t ch) { return false; } -static inline uint8_t +static uint8_t level_factor_for(text_t current, text_t last, WorkSpace *w) { text_t lch = LOWERCASE(last); if (has_char(w->level1, w->level1_len, lch)) return 90; @@ -101,7 +101,7 @@ init_workspace(WorkSpace *w, text_t *haystack, len_t haystack_len) { } -static inline bool +static bool has_atleast_one_match(WorkSpace *w) { int p = -1; bool found; @@ -118,7 +118,7 @@ has_atleast_one_match(WorkSpace *w) { #define POSITION(x) w->positions[x][w->address[x]] -static inline bool +static bool increment_address(WorkSpace *w) { len_t pos = w->needle_len - 1; while(true) { @@ -130,7 +130,7 @@ increment_address(WorkSpace *w) { return false; } -static inline bool +static bool address_is_monotonic(WorkSpace *w) { // Check if the character positions pointed to by the current address are monotonic for (len_t i = 1; i < w->needle_len; i++) { @@ -139,7 +139,7 @@ address_is_monotonic(WorkSpace *w) { return true; } -static inline double +static double calc_score(WorkSpace *w) { double ans = 0; len_t distance, pos; diff --git a/kittens/diff/speedup.c b/kittens/diff/speedup.c index 798828be7..6eee80007 100644 --- a/kittens/diff/speedup.c +++ b/kittens/diff/speedup.c @@ -41,7 +41,7 @@ typedef struct { static const Segment EMPTY_SEGMENT = { .current_pos = UINT_MAX }; -static inline bool +static bool convert_segment(PyObject *highlight, Segment *dest) { PyObject *val = NULL; #define I @@ -62,7 +62,7 @@ convert_segment(PyObject *highlight, Segment *dest) { return true; } -static inline bool +static bool next_segment(SegmentPointer *s, PyObject *highlights) { if (s->pos < s->num) { if (!convert_segment(PyList_GET_ITEM(highlights, s->pos), &s->sg)) return false; @@ -89,7 +89,7 @@ ensure_space(LineBuffer *b, size_t num) { return true; } -static inline bool +static bool insert_code(PyObject *code, LineBuffer *b) { unsigned int csz = PyUnicode_GET_LENGTH(code); if (!ensure_space(b, csz)) return false; @@ -97,7 +97,7 @@ insert_code(PyObject *code, LineBuffer *b) { return true; } -static inline bool +static bool add_line(Segment *bg_segment, Segment *fg_segment, LineBuffer *b, PyObject *ans) { bool bg_is_active = bg_segment->current_pos == bg_segment->end_pos, fg_is_active = fg_segment->current_pos == fg_segment->end_pos; if (bg_is_active) { if(!insert_code(bg_segment->end_code, b)) return false; } diff --git a/kitty/child-monitor.c b/kitty/child-monitor.c index 82a415586..97ef49140 100644 --- a/kitty/child-monitor.c +++ b/kitty/child-monitor.c @@ -111,7 +111,7 @@ static size_t reaped_pids_count = 0; // before ticking over the main loop. Negative values mean wait forever. static monotonic_t maximum_wait = -1; -static inline void +static void set_maximum_wait(monotonic_t val) { if (val >= 0 && (val < maximum_wait || maximum_wait < 0)) maximum_wait = val; } @@ -307,7 +307,7 @@ shutdown_monitor(ChildMonitor *self, PyObject *a UNUSED) { Py_RETURN_NONE; } -static inline bool +static bool do_parse(ChildMonitor *self, Screen *screen, monotonic_t now) { bool input_read = false; screen_mutex(lock, read); @@ -414,7 +414,7 @@ parse_input(ChildMonitor *self) { return input_read; } -static inline void +static void mark_child_for_close(ChildMonitor *self, id_type window_id) { children_mutex(lock); for (size_t i = 0; i < self->count; i++) { @@ -437,7 +437,7 @@ mark_for_close(ChildMonitor *self, PyObject *args) { Py_RETURN_NONE; } -static inline bool +static bool pty_resize(int fd, struct winsize *dim) { while(true) { if (ioctl(fd, TIOCSWINSZ, dim) == -1) { @@ -515,7 +515,7 @@ pyset_iutf8(ChildMonitor *self, PyObject *args) { extern void cocoa_update_menu_bar_title(PyObject*); -static inline void +static void collect_cursor_info(CursorRenderInfo *ans, Window *w, monotonic_t now, OSWindow *os_window) { ScreenRenderData *rd = &w->render_data; Cursor *cursor = rd->screen->cursor; @@ -542,7 +542,7 @@ collect_cursor_info(CursorRenderInfo *ans, Window *w, monotonic_t now, OSWindow ans->is_focused = os_window->is_focused; } -static inline void +static void change_menubar_title(PyObject *title UNUSED) { #ifdef __APPLE__ static PyObject *current_title = NULL; @@ -553,7 +553,7 @@ change_menubar_title(PyObject *title UNUSED) { #endif } -static inline bool +static bool prepare_to_render_os_window(OSWindow *os_window, monotonic_t now, unsigned int *active_window_id, color_type *active_window_bg, unsigned int *num_visible_windows, bool *all_windows_have_same_bg, bool scan_for_animated_images) { #define TD os_window->tab_bar_render_data bool needs_render = os_window->needs_render; @@ -614,7 +614,7 @@ prepare_to_render_os_window(OSWindow *os_window, monotonic_t now, unsigned int * return needs_render; } -static inline void +static void render_os_window(OSWindow *os_window, monotonic_t now, unsigned int active_window_id, color_type active_window_bg, unsigned int num_visible_windows, bool all_windows_have_same_bg) { // ensure all pixels are cleared to background color at least once in every buffer if (os_window->clear_count++ < 3) blank_os_window(os_window); @@ -664,7 +664,7 @@ draw_resizing_text(OSWindow *w) { } } -static inline bool +static bool no_render_frame_received_recently(OSWindow *w, monotonic_t now, monotonic_t max_wait) { bool ans = now - w->last_render_frame_received_at > max_wait; if (ans && global_state.debug_rendering) { @@ -677,7 +677,7 @@ no_render_frame_received_recently(OSWindow *w, monotonic_t now, monotonic_t max_ return ans; } -static inline void +static void render(monotonic_t now, bool input_read) { EVDBG("input_read: %d, check_for_active_animated_images: %d", input_read, global_state.check_for_active_animated_images); static monotonic_t last_render_at = MONOTONIC_T_MIN; @@ -736,7 +736,7 @@ render(monotonic_t now, bool input_read) { typedef struct { int fd; uint8_t *buf; size_t sz; } ThreadWriteData; -static inline ThreadWriteData* +static ThreadWriteData* alloc_twd(size_t sz) { ThreadWriteData *data = calloc(1, sizeof(ThreadWriteData)); if (data != NULL) { @@ -747,7 +747,7 @@ alloc_twd(size_t sz) { return data; } -static inline void +static void free_twd(ThreadWriteData *x) { if (x != NULL) free(x->buf); free(x); @@ -770,7 +770,7 @@ monitor_pid(PyObject *self UNUSED, PyObject *args) { Py_RETURN_NONE; } -static inline void +static void report_reaped_pids(void) { children_mutex(lock); if (reaped_pids_count) { @@ -860,7 +860,7 @@ remove_python_timer(PyObject *self UNUSED, PyObject *args) { } -static inline void +static void process_pending_resizes(monotonic_t now) { global_state.has_pending_resizes = false; for (size_t i = 0; i < global_state.num_os_windows; i++) { @@ -890,7 +890,7 @@ process_pending_resizes(monotonic_t now) { } } -static inline void +static void close_os_window(ChildMonitor *self, OSWindow *os_window) { destroy_os_window(os_window); call_boss(on_os_window_closed, "Kii", os_window->id, os_window->window_width, os_window->window_height); @@ -901,7 +901,7 @@ close_os_window(ChildMonitor *self, OSWindow *os_window) { remove_os_window(os_window->id); } -static inline bool +static bool process_pending_closes(ChildMonitor *self) { if (global_state.quit_request == CONFIRMABLE_CLOSE_REQUESTED) { call_boss(quit, ""); @@ -1075,7 +1075,7 @@ main_loop(ChildMonitor *self, PyObject *a UNUSED) { // I/O thread functions {{{ -static inline void +static void add_children(ChildMonitor *self) { for (; add_queue_count > 0 && self->count < MAX_CHILDREN;) { add_queue_count--; @@ -1088,7 +1088,7 @@ add_children(ChildMonitor *self) { } -static inline void +static void hangup(pid_t pid) { errno = 0; pid_t pgid = getpgid(pid); @@ -1100,14 +1100,14 @@ hangup(pid_t pid) { } -static inline void +static void cleanup_child(ssize_t i) { safe_close(children[i].fd, __FILE__, __LINE__); hangup(children[i].pid); } -static inline void +static void remove_children(ChildMonitor *self) { if (self->count > 0) { size_t count = 0; @@ -1186,7 +1186,7 @@ handle_signal(int signum, void *data) { } } -static inline void +static void mark_child_for_removal(ChildMonitor *self, pid_t pid) { children_mutex(lock); for (size_t i = 0; i < self->count; i++) { @@ -1198,7 +1198,7 @@ mark_child_for_removal(ChildMonitor *self, pid_t pid) { children_mutex(unlock); } -static inline void +static void mark_monitored_pids(pid_t pid, int status) { children_mutex(lock); for (ssize_t i = monitored_pids_count - 1; i >= 0; i--) { @@ -1213,7 +1213,7 @@ mark_monitored_pids(pid_t pid, int status) { children_mutex(unlock); } -static inline void +static void reap_children(ChildMonitor *self, bool enable_close_on_child_death) { int status; pid_t pid; @@ -1229,7 +1229,7 @@ reap_children(ChildMonitor *self, bool enable_close_on_child_death) { } } -static inline void +static void write_to_child(int fd, Screen *screen) { size_t written = 0; ssize_t ret = 0; @@ -1387,7 +1387,7 @@ typedef struct pollfd PollFD; #define PEER_LIMIT 256 #define nuke_socket(s) { shutdown(s, SHUT_RDWR); safe_close(s, __FILE__, __LINE__); } -static inline bool +static bool accept_peer(int listen_fd, bool shutting_down) { int peer = accept(listen_fd, NULL, NULL); if (UNLIKELY(peer == -1)) { @@ -1408,7 +1408,7 @@ accept_peer(int listen_fd, bool shutting_down) { return true; } -static inline void +static void free_peer(Peer *peer) { free(peer->read.data); peer->read.data = NULL; free(peer->write.data); peer->write.data = NULL; @@ -1417,7 +1417,7 @@ free_peer(Peer *peer) { #define KITTY_CMD_PREFIX "\x1bP@kitty-cmd{" -static inline void +static void queue_peer_message(ChildMonitor *self, Peer *peer) { talk_mutex(lock); ensure_space_for(self, messages, Message, self->messages_count + 16, messages_capacity, 16, true); @@ -1436,7 +1436,7 @@ queue_peer_message(ChildMonitor *self, Peer *peer) { wakeup_main_loop(); } -static inline bool +static bool has_complete_peer_command(Peer *peer) { peer->read.command_end = 0; if (peer->read.used > sizeof(KITTY_CMD_PREFIX) && memcmp(peer->read.data, KITTY_CMD_PREFIX, sizeof(KITTY_CMD_PREFIX)-1) == 0) { @@ -1451,7 +1451,7 @@ has_complete_peer_command(Peer *peer) { } -static inline void +static void dispatch_peer_command(ChildMonitor *self, Peer *peer) { if (peer->read.command_end) { size_t used = peer->read.used; @@ -1466,7 +1466,7 @@ dispatch_peer_command(ChildMonitor *self, Peer *peer) { } } -static inline void +static void read_from_peer(ChildMonitor *self, Peer *peer) { #define failed(msg) { log_error("Reading from peer failed: %s", msg); shutdown(peer->fd, SHUT_RD); peer->read.finished = true; return; } if (peer->read.used >= peer->read.capacity) { @@ -1492,7 +1492,7 @@ read_from_peer(ChildMonitor *self, Peer *peer) { #undef failed } -static inline void +static void write_to_peer(Peer *peer) { talk_mutex(lock); ssize_t n = send(peer->fd, peer->write.data, peer->write.used, MSG_NOSIGNAL); @@ -1512,7 +1512,7 @@ wakeup_talk_loop(bool in_signal_handler) { } -static inline void +static void prune_peers(void) { for (size_t i = 0; i < talk_data.num_peers; i++) { size_t idx = talk_data.num_peers - 1 - i; diff --git a/kitty/child.c b/kitty/child.c index 886e6a889..920da0a0b 100644 --- a/kitty/child.c +++ b/kitty/child.c @@ -16,7 +16,7 @@ #include #include -static inline char** +static char** serialize_string_tuple(PyObject *src) { Py_ssize_t sz = PyTuple_GET_SIZE(src); @@ -32,7 +32,7 @@ serialize_string_tuple(PyObject *src) { return ans; } -static inline void +static void free_string_tuple(char** data) { size_t i = 0; while(data[i]) free(data[i++]); @@ -41,7 +41,7 @@ free_string_tuple(char** data) { extern char **environ; -static inline void +static void write_to_stderr(const char *text) { size_t sz = strlen(text); size_t written = 0; @@ -58,7 +58,7 @@ write_to_stderr(const char *text) { #define exit_on_err(m) { write_to_stderr(m); write_to_stderr(": "); write_to_stderr(strerror(errno)); exit(EXIT_FAILURE); } -static inline void +static void wait_for_terminal_ready(int fd) { char data; while(1) { diff --git a/kitty/colors.c b/kitty/colors.c index 3943a1cee..0cb28a9ba 100644 --- a/kitty/colors.c +++ b/kitty/colors.c @@ -30,7 +30,7 @@ static uint32_t FG_BG_256[256] = { 0xffffff, // 15 }; -static inline void +static void init_FG_BG_table(void) { if (UNLIKELY(FG_BG_256[255] == 0)) { // colors 16..232: the 6x6x6 color cube @@ -111,7 +111,7 @@ copy_color_profile(ColorProfile *dest, ColorProfile *src) { dest->dirty = true; } -static inline void +static void patch_color_table(const char *key, PyObject *profiles, PyObject *spec, size_t which, int change_configured) { PyObject *v = PyDict_GetItemString(spec, key); if (v) { diff --git a/kitty/core_text.m b/kitty/core_text.m index 0ab9d03cb..70fd10168 100644 --- a/kitty/core_text.m +++ b/kitty/core_text.m @@ -34,7 +34,7 @@ typedef struct { } CTFace; PyTypeObject CTFace_Type; -static inline char* +static char* convert_cfstring(CFStringRef src, int free_src) { #define SZ 4094 static char buf[SZ+2] = {0}; @@ -46,7 +46,7 @@ convert_cfstring(CFStringRef src, int free_src) { #undef SZ } -static inline void +static void init_face(CTFace *self, CTFontRef font, FONTS_DATA_HANDLE fg UNUSED) { if (self->hb_font) hb_font_destroy(self->hb_font); self->hb_font = NULL; @@ -61,7 +61,7 @@ init_face(CTFace *self, CTFontRef font, FONTS_DATA_HANDLE fg UNUSED) { self->scaled_point_sz = CTFontGetSize(self->ct_font); } -static inline CTFace* +static CTFace* ct_face(CTFontRef font, FONTS_DATA_HANDLE fg) { CTFace *self = (CTFace *)CTFace_Type.tp_alloc(&CTFace_Type, 0); if (self) { @@ -174,7 +174,7 @@ coretext_all_fonts(PyObject UNUSED *_self) { return ans; } -static inline unsigned int +static unsigned int glyph_id_for_codepoint_ctfont(CTFontRef ct_font, char_type ch) { unichar chars[2] = {0}; CGGlyph glyphs[2] = {0}; @@ -183,7 +183,7 @@ glyph_id_for_codepoint_ctfont(CTFontRef ct_font, char_type ch) { return glyphs[0]; } -static inline bool +static bool is_last_resort_font(CTFontRef new_font) { CFStringRef name = CTFontCopyPostScriptName(new_font); CFComparisonResult cr = CFStringCompare(name, CFSTR("LastResort"), 0); @@ -191,7 +191,7 @@ is_last_resort_font(CTFontRef new_font) { return cr == kCFCompareEqualTo; } -static inline CTFontRef +static CTFontRef manually_search_fallback_fonts(CTFontRef current_font, CPUCell *cell) { CFArrayRef fonts = CTFontCollectionCreateMatchingFontDescriptors(all_fonts_collection()); CTFontRef ans = NULL; @@ -220,7 +220,7 @@ manually_search_fallback_fonts(CTFontRef current_font, CPUCell *cell) { return ans; } -static inline CTFontRef +static CTFontRef find_substitute_face(CFStringRef str, CTFontRef old_font, CPUCell *cpu_cell) { // CTFontCreateForString returns the original font when there are combining // diacritics in the font and the base character is in the original font, @@ -296,7 +296,7 @@ get_glyph_width(PyObject *s, glyph_index g) { return (int)ceil(bounds.size.width); } -static inline float +static float scaled_point_sz(FONTS_DATA_HANDLE fg) { return ((fg->logical_dpi_x + fg->logical_dpi_y) / 144.0) * fg->font_sz_in_pts; } @@ -448,7 +448,7 @@ finalize(void) { } -static inline void +static void render_color_glyph(CTFontRef font, uint8_t *buf, int glyph_id, unsigned int width, unsigned int height, unsigned int baseline) { CGColorSpaceRef color_space = CGColorSpaceCreateDeviceRGB(); if (color_space == NULL) fatal("Out of memory"); @@ -492,7 +492,7 @@ ensure_render_space(size_t width, size_t height, size_t num_glyphs) { } } -static inline void +static void render_glyphs(CTFontRef font, unsigned int width, unsigned int height, unsigned int baseline, unsigned int num_glyphs) { memset(buffers.render_buf, 0, width * height); CGColorSpaceRef gray_color_space = CGColorSpaceCreateDeviceGray(); @@ -538,7 +538,7 @@ render_simple_text_impl(PyObject *s, const char *text, unsigned int baseline) { } -static inline bool +static bool do_render(CTFontRef ct_font, bool bold, bool italic, hb_glyph_info_t *info, hb_glyph_position_t *hb_positions, unsigned int num_glyphs, pixel *canvas, unsigned int cell_width, unsigned int cell_height, unsigned int num_cells, unsigned int baseline, bool *was_colored, bool allow_resize, FONTS_DATA_HANDLE fg, bool center_glyph) { unsigned int canvas_width = cell_width * num_cells; ensure_render_space(canvas_width, cell_height, num_glyphs); diff --git a/kitty/cursor.c b/kitty/cursor.c index 69420b74a..fbf0fc51c 100644 --- a/kitty/cursor.c +++ b/kitty/cursor.c @@ -46,7 +46,7 @@ cursor_reset_display_attrs(Cursor *self) { } -static inline void +static void parse_color(int *params, unsigned int *i, unsigned int count, uint32_t *result) { unsigned int attr; uint8_t r, g, b; diff --git a/kitty/data-types.c b/kitty/data-types.c index 613e1725e..cfe831341 100644 --- a/kitty/data-types.c +++ b/kitty/data-types.c @@ -91,7 +91,7 @@ stop_profiler(PyObject UNUSED *self, PyObject *args UNUSED) { } #endif -static inline bool +static bool put_tty_in_raw_mode(int fd, const struct termios* termios_p, bool read_with_timeout, int optional_actions) { struct termios raw_termios = *termios_p; cfmakeraw(&raw_termios); diff --git a/kitty/disk-cache.c b/kitty/disk-cache.c index 3915a375e..75d1d8f60 100644 --- a/kitty/disk-cache.c +++ b/kitty/disk-cache.c @@ -158,7 +158,7 @@ copy_between_files(int infd, int outfd, off_t in_pos, size_t len, uint8_t *buf, return true; } -static inline off_t +static off_t size_of_cache_file(DiskCache *self) { return lseek(self->cache_file_fd, 0, SEEK_END); } @@ -255,7 +255,7 @@ cmp_pos_in_cache_file(void *a_, void *b_) { return a->pos_in_cache_file - b->pos_in_cache_file; } -static inline void +static void find_hole(DiskCache *self) { off_t required_size = self->currently_writing.data_sz, prev = -100; HASH_SORT(self->entries, cmp_pos_in_cache_file); @@ -271,7 +271,7 @@ find_hole(DiskCache *self) { } } -static inline bool +static bool find_cache_entry_to_write(DiskCache *self) { CacheEntry *tmp, *s; off_t size_on_disk = size_of_cache_file(self); @@ -298,7 +298,7 @@ find_cache_entry_to_write(DiskCache *self) { return false; } -static inline bool +static bool write_dirty_entry(DiskCache *self) { size_t left = self->currently_writing.data_sz; uint8_t *p = self->currently_writing.data; @@ -330,7 +330,7 @@ write_dirty_entry(DiskCache *self) { return true; } -static inline void +static void retire_currently_writing(DiskCache *self) { CacheEntry *s = NULL; HASH_FIND(hh, self->entries, self->currently_writing.hash_key, self->currently_writing.hash_keylen, s); @@ -477,7 +477,7 @@ dealloc(DiskCache* self) { Py_TYPE(self)->tp_free((PyObject*)self); } -static inline CacheEntry* +static CacheEntry* create_cache_entry(const void *key, const size_t key_sz) { CacheEntry *s = calloc(1, sizeof(CacheEntry)); if (!s) return (CacheEntry*)PyErr_NoMemory(); diff --git a/kitty/fontconfig.c b/kitty/fontconfig.c index 3c0db030c..4858b32ad 100644 --- a/kitty/fontconfig.c +++ b/kitty/fontconfig.c @@ -35,10 +35,10 @@ finalize(void) { } } -static inline PyObject* +static PyObject* pybool(FcBool x) { PyObject *ans = x ? Py_True: Py_False; Py_INCREF(ans); return ans; } -static inline PyObject* +static PyObject* pyspacing(int val) { #define S(x) case FC_##x: return PyUnicode_FromString(#x) switch(val) { S(PROPORTIONAL); S(DUAL); S(MONO); S(CHARCELL); default: return PyUnicode_FromString("UNKNOWN"); } @@ -46,7 +46,7 @@ pyspacing(int val) { } -static inline PyObject* +static PyObject* pattern_as_dict(FcPattern *pat) { PyObject *ans = PyDict_New(), *p = NULL, *list = NULL; if (ans == NULL) return NULL; @@ -112,7 +112,7 @@ exit: #undef LS } -static inline PyObject* +static PyObject* font_set(FcFontSet *fs) { PyObject *ans = PyTuple_New(fs->nfont); if (ans == NULL) return NULL; @@ -154,7 +154,7 @@ end: return ans; } -static inline PyObject* +static PyObject* _fc_match(FcPattern *pat) { FcPattern *match = NULL; PyObject *ans = NULL; @@ -172,7 +172,7 @@ end: static char_type char_buf[1024]; -static inline void +static void add_charset(FcPattern *pat, size_t num) { FcCharSet *charset = NULL; if (num) { @@ -190,7 +190,7 @@ end: if (charset != NULL) FcCharSetDestroy(charset); } -static inline bool +static bool _native_fc_match(FcPattern *pat, FontConfigFace *ans) { bool ok = false; FcPattern *match = NULL; diff --git a/kitty/fonts.c b/kitty/fonts.c index ae0157298..250bfd38d 100644 --- a/kitty/fonts.c +++ b/kitty/fonts.c @@ -101,7 +101,7 @@ ensure_canvas_can_fit(FontGroup *fg, unsigned cells) { } -static inline void +static void save_window_font_groups(void) { for (size_t o = 0; o < global_state.num_os_windows; o++) { OSWindow *w = global_state.os_windows + o; @@ -109,7 +109,7 @@ save_window_font_groups(void) { } } -static inline void +static void restore_window_font_groups(void) { for (size_t o = 0; o < global_state.num_os_windows; o++) { OSWindow *w = global_state.os_windows + o; @@ -123,7 +123,7 @@ restore_window_font_groups(void) { } } -static inline bool +static bool font_group_is_unused(FontGroup *fg) { for (size_t o = 0; o < global_state.num_os_windows; o++) { OSWindow *w = global_state.os_windows + o; @@ -140,7 +140,7 @@ free_maps(Font *font) { font->glyph_properties_hash_table = NULL; } -static inline void +static void del_font(Font *f) { Py_CLEAR(f->face); free(f->ffs_hb_features); f->ffs_hb_features = NULL; @@ -148,7 +148,7 @@ del_font(Font *f) { f->bold = false; f->italic = false; } -static inline void +static void del_font_group(FontGroup *fg) { free(fg->canvas.buf); fg->canvas.buf = NULL; fg->canvas = (Canvas){0}; fg->sprite_map = free_sprite_map(fg->sprite_map); @@ -156,7 +156,7 @@ del_font_group(FontGroup *fg) { free(fg->fonts); fg->fonts = NULL; } -static inline void +static void trim_unused_font_groups(void) { save_window_font_groups(); size_t i = 0; @@ -171,7 +171,7 @@ trim_unused_font_groups(void) { restore_window_font_groups(); } -static inline void +static void add_font_group(void) { if (num_font_groups) trim_unused_font_groups(); if (num_font_groups >= font_groups_capacity) { @@ -184,7 +184,7 @@ add_font_group(void) { num_font_groups++; } -static inline FontGroup* +static FontGroup* font_group_for(double font_sz_in_pts, double logical_dpi_x, double logical_dpi_y) { for (size_t i = 0; i < num_font_groups; i++) { FontGroup *fg = font_groups + i; @@ -205,7 +205,7 @@ font_group_for(double font_sz_in_pts, double logical_dpi_x, double logical_dpi_y // Sprites {{{ -static inline void +static void sprite_map_set_error(int error) { switch(error) { case 1: @@ -223,7 +223,7 @@ sprite_tracker_set_limits(size_t max_texture_size_, size_t max_array_len_) { max_array_len = MIN(0xfffu, max_array_len_); } -static inline void +static void do_increment(FontGroup *fg, int *error) { fg->sprite_tracker.x++; if (fg->sprite_tracker.x >= fg->sprite_tracker.xnum) { @@ -265,7 +265,7 @@ sprite_tracker_set_layout(GPUSpriteTracker *sprite_tracker, unsigned int cell_wi } // }}} -static inline PyObject* +static PyObject* desc_to_face(PyObject *desc, FONTS_DATA_HANDLE fg) { PyObject *d = specialize_font_descriptor(desc, fg); if (d == NULL) return NULL; @@ -274,7 +274,7 @@ desc_to_face(PyObject *desc, FONTS_DATA_HANDLE fg) { return ans; } -static inline bool +static bool init_font(Font *f, PyObject *face, bool bold, bool italic, bool emoji_presentation) { f->face = face; Py_INCREF(f->face); f->bold = bold; f->italic = italic; f->emoji_presentation = emoji_presentation; @@ -311,7 +311,7 @@ init_font(Font *f, PyObject *face, bool bold, bool italic, bool emoji_presentati return true; } -static inline void +static void free_font_groups(void) { if (font_groups) { for (size_t i = 0; i < num_font_groups; i++) del_font_group(font_groups + i); @@ -332,7 +332,7 @@ python_send_to_gpu(FONTS_DATA_HANDLE fg, unsigned int x, unsigned int y, unsigne } -static inline void +static void calc_cell_metrics(FontGroup *fg) { unsigned int cell_height, cell_width, baseline, underline_position, underline_thickness, strikethrough_position, strikethrough_thickness; cell_metrics(fg->fonts[fg->medium_font_idx].face, &cell_width, &cell_height, &baseline, &underline_position, &underline_thickness, &strikethrough_position, &strikethrough_thickness); @@ -371,17 +371,17 @@ calc_cell_metrics(FontGroup *fg) { ensure_canvas_can_fit(fg, 8); } -static inline bool +static bool face_has_codepoint(PyObject* face, char_type cp) { return glyph_id_for_codepoint(face, cp) > 0; } -static inline bool +static bool has_emoji_presentation(CPUCell *cpu_cell, GPUCell *gpu_cell) { return (gpu_cell->attrs & WIDTH_MASK) == 2 && is_emoji(cpu_cell->ch) && cpu_cell->cc_idx[0] != VS15; } -static inline bool +static bool has_cell_text(Font *self, CPUCell *cell) { if (!face_has_codepoint(self->face, cell->ch)) return false; char_type combining_chars[arraysz(cell->cc_idx)]; @@ -403,7 +403,7 @@ has_cell_text(Font *self, CPUCell *cell) { return true; } -static inline void +static void output_cell_fallback_data(CPUCell *cell, bool bold, bool italic, bool emoji_presentation, PyObject *face, bool new_face) { printf("U+%x ", cell->ch); for (unsigned i = 0; i < arraysz(cell->cc_idx) && cell->cc_idx[i]; i++) { @@ -417,7 +417,7 @@ output_cell_fallback_data(CPUCell *cell, bool bold, bool italic, bool emoji_pres printf("\n"); } -static inline ssize_t +static ssize_t load_fallback_font(FontGroup *fg, CPUCell *cell, bool bold, bool italic, bool emoji_presentation) { if (fg->fallback_fonts_count > 100) { log_error("Too many fallback fonts"); return MISSING_FONT; } ssize_t f; @@ -456,7 +456,7 @@ load_fallback_font(FontGroup *fg, CPUCell *cell, bool bold, bool italic, bool em return ans; } -static inline ssize_t +static ssize_t fallback_font(FontGroup *fg, CPUCell *cpu_cell, GPUCell *gpu_cell) { bool bold = (gpu_cell->attrs >> BOLD_SHIFT) & 1; bool italic = (gpu_cell->attrs >> ITALIC_SHIFT) & 1; @@ -474,7 +474,7 @@ fallback_font(FontGroup *fg, CPUCell *cpu_cell, GPUCell *gpu_cell) { return load_fallback_font(fg, cpu_cell, bold, italic, emoji_presentation); } -static inline ssize_t +static ssize_t in_symbol_maps(FontGroup *fg, char_type ch) { for (size_t i = 0; i < num_symbol_maps; i++) { if (symbol_maps[i].left <= ch && ch <= symbol_maps[i].right) return fg->first_symbol_font_idx + symbol_maps[i].font_idx; @@ -491,7 +491,7 @@ in_symbol_maps(FontGroup *fg, char_type ch) { // - BLANK_FONT // - BOX_FONT // - an index in the fonts list -static inline ssize_t +static ssize_t font_for_cell(FontGroup *fg, CPUCell *cpu_cell, GPUCell *gpu_cell, bool *is_fallback_font, bool *is_emoji_presentation) { *is_fallback_font = false; *is_emoji_presentation = false; @@ -531,13 +531,13 @@ START_ALLOW_CASE_RANGE END_ALLOW_CASE_RANGE } -static inline void +static void set_sprite(GPUCell *cell, sprite_index x, sprite_index y, sprite_index z) { cell->sprite_x = x; cell->sprite_y = y; cell->sprite_z = z; } // Gives a unique (arbitrary) id to a box glyph -static inline glyph_index +static glyph_index box_glyph_id(char_type ch) { START_ALLOW_CASE_RANGE switch(ch) { @@ -596,7 +596,7 @@ render_box_cell(FontGroup *fg, CPUCell *cpu_cell, GPUCell *gpu_cell) { Py_DECREF(ret); } -static inline void +static void load_hb_buffer(CPUCell *first_cpu_cell, GPUCell *first_gpu_cell, index_type num_cells) { index_type num; hb_buffer_clear_contents(harfbuzz_buffer); @@ -617,13 +617,13 @@ load_hb_buffer(CPUCell *first_cpu_cell, GPUCell *first_gpu_cell, index_type num_ } -static inline void +static void set_cell_sprite(GPUCell *cell, const SpritePosition *sp) { cell->sprite_x = sp->x; cell->sprite_y = sp->y; cell->sprite_z = sp->z; if (sp->colored) cell->sprite_z |= 0x4000; } -static inline pixel* +static pixel* extract_cell_from_canvas(FontGroup *fg, unsigned int i, unsigned int num_cells) { pixel *ans = fg->canvas.buf + (fg->cell_width * fg->cell_height * (fg->canvas.current_cells - 1)), *dest = ans, *src = fg->canvas.buf + (i * fg->cell_width); unsigned int stride = fg->cell_width * num_cells; @@ -638,7 +638,7 @@ typedef struct GlyphRenderScratch { } GlyphRenderScratch; static GlyphRenderScratch global_glyph_render_scratch = {0}; -static inline void +static void render_group(FontGroup *fg, unsigned int num_cells, unsigned int num_glyphs, CPUCell *cpu_cells, GPUCell *gpu_cells, hb_glyph_info_t *info, hb_glyph_position_t *positions, Font *font, glyph_index *glyphs, unsigned glyph_count, bool center_glyph) { #define sp global_glyph_render_scratch.sprite_positions int error = 0; @@ -703,14 +703,14 @@ typedef struct { static GroupState group_state = {0}; -static inline unsigned int +static unsigned int num_codepoints_in_cell(CPUCell *cell) { unsigned int ans = 1; for (unsigned i = 0; i < arraysz(cell->cc_idx) && cell->cc_idx[i]; i++) ans++; return ans; } -static inline void +static void shape(CPUCell *first_cpu_cell, GPUCell *first_gpu_cell, index_type num_cells, hb_font_t *font, Font *fobj, bool disable_ligature) { if (group_state.groups_capacity <= 2 * num_cells) { group_state.groups_capacity = MAX(128u, 2 * num_cells); // avoid unnecessary reallocs @@ -747,7 +747,7 @@ shape(CPUCell *first_cpu_cell, GPUCell *first_gpu_cell, index_type num_cells, hb else group_state.num_glyphs = MIN(info_length, positions_length); } -static inline bool +static bool is_special_glyph(glyph_index glyph_id, Font *font, CellData* cell_data) { // A glyph is special if the codepoint it corresponds to matches a // different glyph in the font @@ -764,7 +764,7 @@ is_special_glyph(glyph_index glyph_id, Font *font, CellData* cell_data) { return s->data & SPECIAL_VALUE_MASK; } -static inline bool +static bool is_empty_glyph(glyph_index glyph_id, Font *font) { // A glyph is empty if its metrics have a width of zero GlyphProperties *s = find_or_create_glyph_properties(&font->glyph_properties_hash_table, glyph_id); @@ -776,7 +776,7 @@ is_empty_glyph(glyph_index glyph_id, Font *font) { return s->data & EMPTY_VALUE_MASK; } -static inline unsigned int +static unsigned int check_cell_consumed(CellData *cell_data, CPUCell *last_cpu_cell) { cell_data->codepoints_consumed++; if (cell_data->codepoints_consumed >= cell_data->num_codepoints) { @@ -806,7 +806,7 @@ check_cell_consumed(CellData *cell_data, CPUCell *last_cpu_cell) { return 0; } -static inline LigatureType +static LigatureType ligature_type_from_glyph_name(const char *glyph_name, SpacerStrategy strategy) { const char *p, *m, *s, *e; if (strategy == SPACERS_IOSEVKA) { @@ -826,7 +826,7 @@ ligature_type_from_glyph_name(const char *glyph_name, SpacerStrategy strategy) { #define G(x) (group_state.x) -static inline void +static void detect_spacer_strategy(hb_font_t *hbf, Font *font) { CPUCell cpu_cells[3] = {{.ch = '='}, {.ch = '='}, {.ch = '='}}; GPUCell gpu_cells[3] = {{.attrs = 1}, {.attrs = 1}, {.attrs = 1}}; @@ -1071,7 +1071,7 @@ shape_run(CPUCell *first_cpu_cell, GPUCell *first_gpu_cell, index_type num_cells #endif } -static inline void +static void merge_groups_for_pua_space_ligature(void) { while (G(group_idx) > 0) { Group *g = G(groups), *g1 = G(groups) + 1; @@ -1084,14 +1084,14 @@ merge_groups_for_pua_space_ligature(void) { #undef MOVE_GLYPH_TO_NEXT_GROUP -static inline bool +static bool is_group_calt_ligature(const Group *group) { GPUCell *first_cell = G(first_gpu_cell) + group->first_cell_idx; return group->num_cells > 1 && group->has_special_glyph && (first_cell->attrs & WIDTH_MASK) == 1; } -static inline void +static void split_run_at_offset(index_type cursor_offset, index_type *left, index_type *right) { *left = 0; *right = 0; for (unsigned idx = 0; idx < G(group_idx) + 1; idx++) { @@ -1107,7 +1107,7 @@ split_run_at_offset(index_type cursor_offset, index_type *left, index_type *righ } -static inline void +static void render_groups(FontGroup *fg, Font *font, bool center_glyph) { unsigned idx = 0; while (idx <= G(group_idx)) { @@ -1174,7 +1174,7 @@ test_shape(PyObject UNUSED *self, PyObject *args) { } #undef G -static inline void +static void render_run(FontGroup *fg, CPUCell *first_cpu_cell, GPUCell *first_gpu_cell, index_type num_cells, ssize_t font_idx, bool pua_space_ligature, bool center_glyph, int cursor_offset, DisableLigature disable_ligature_strategy) { switch(font_idx) { default: @@ -1211,7 +1211,7 @@ render_run(FontGroup *fg, CPUCell *first_cpu_cell, GPUCell *first_gpu_cell, inde } } -static inline bool +static bool is_non_emoji_dingbat(char_type ch) { return 0x2700 <= ch && ch <= 0x27bf && !is_emoji(ch); } @@ -1295,7 +1295,7 @@ render_simple_text(FONTS_DATA_HANDLE fg_, const char *text) { return ans; } -static inline void +static void clear_symbol_maps(void) { if (symbol_maps) { free(symbol_maps); symbol_maps = NULL; num_symbol_maps = 0; } } @@ -1329,7 +1329,7 @@ set_font_data(PyObject UNUSED *m, PyObject *args) { Py_RETURN_NONE; } -static inline void +static void send_prerendered_sprites(FontGroup *fg) { int error = 0; sprite_index x = 0, y = 0, z = 0; @@ -1354,7 +1354,7 @@ send_prerendered_sprites(FontGroup *fg) { Py_CLEAR(args); } -static inline size_t +static size_t initialize_font(FontGroup *fg, unsigned int desc_idx, const char *ftype) { PyObject *d = PyObject_CallFunction(descriptor_for_idx, "I", desc_idx); if (d == NULL) { PyErr_Print(); fatal("Failed for %s font", ftype); } diff --git a/kitty/freetype.c b/kitty/freetype.c index ac52a95e3..581935c82 100644 --- a/kitty/freetype.c +++ b/kitty/freetype.c @@ -76,18 +76,18 @@ static FT_Library library; FT_Library freetype_library(void) { return library; } -static inline int +static int font_units_to_pixels_y(Face *self, int x) { return (int)ceil((double)FT_MulFix(x, self->face->size->metrics.y_scale) / 64.0); } -static inline int +static int font_units_to_pixels_x(Face *self, int x) { return (int)ceil((double)FT_MulFix(x, self->face->size->metrics.x_scale) / 64.0); } -static inline int +static int get_load_flags(int hinting, int hintstyle, int base) { int flags = base; if (hinting) { @@ -98,7 +98,7 @@ get_load_flags(int hinting, int hintstyle, int base) { } -static inline bool +static bool load_glyph(Face *self, int glyph_index, int load_type) { int flags = get_load_flags(self->hinting, self->hintstyle, load_type); int error = FT_Load_Glyph(self->face, glyph_index, flags); @@ -110,7 +110,7 @@ load_glyph(Face *self, int glyph_index, int load_type) { return true; } -static inline unsigned int +static unsigned int get_height_for_char(Face *self, char ch) { unsigned int ans = 0; int glyph_index = FT_Get_Char_Index(self->face, ch); @@ -125,7 +125,7 @@ get_height_for_char(Face *self, char ch) { return ans; } -static inline unsigned int +static unsigned int calc_cell_height(Face *self, bool for_metrics) { unsigned int ans = font_units_to_pixels_y(self, self->height); if (for_metrics) { @@ -139,7 +139,7 @@ calc_cell_height(Face *self, bool for_metrics) { return ans; } -static inline bool +static bool set_font_size(Face *self, FT_F26Dot6 char_width, FT_F26Dot6 char_height, FT_UInt xdpi, FT_UInt ydpi, unsigned int desired_height, unsigned int cell_height) { int error = FT_Set_Char_Size(self->face, 0, char_height, xdpi, ydpi); if (!error) { @@ -189,7 +189,7 @@ set_size_for_face(PyObject *s, unsigned int desired_height, bool force, FONTS_DA return set_font_size(self, w, w, xdpi, ydpi, desired_height, fg->cell_height); } -static inline bool +static bool init_ft_face(Face *self, PyObject *path, int hinting, int hintstyle, FONTS_DATA_HANDLE fg) { #define CPY(n) self->n = self->face->n; CPY(units_per_EM); CPY(ascender); CPY(descender); CPY(height); CPY(max_advance_width); CPY(max_advance_height); CPY(underline_position); CPY(underline_thickness); @@ -290,7 +290,7 @@ postscript_name_for_face(const PyObject *face_) { return ps_name ? ps_name : ""; } -static inline unsigned int +static unsigned int calc_cell_width(Face *self) { unsigned int ans = 0; for (char_type i = 32; i < 128; i++) { @@ -382,7 +382,7 @@ typedef struct { int bitmap_left, bitmap_top; } ProcessedBitmap; -static inline void +static void free_processed_bitmap(ProcessedBitmap *bm) { if (bm->needs_free) { bm->needs_free = false; @@ -390,7 +390,7 @@ free_processed_bitmap(ProcessedBitmap *bm) { } } -static inline void +static void trim_borders(ProcessedBitmap *ans, size_t extra) { bool column_has_text = false; @@ -407,7 +407,7 @@ trim_borders(ProcessedBitmap *ans, size_t extra) { ans->width -= extra; } -static inline void +static void populate_processed_bitmap(FT_GlyphSlotRec *slot, FT_Bitmap *bitmap, ProcessedBitmap *ans, bool copy_buf) { ans->stride = bitmap->pitch < 0 ? -bitmap->pitch : bitmap->pitch; ans->rows = bitmap->rows; @@ -438,7 +438,7 @@ freetype_convert_mono_bitmap(FT_Bitmap *src, FT_Bitmap *dest) { return true; } -static inline bool +static bool render_bitmap(Face *self, int glyph_id, ProcessedBitmap *ans, unsigned int cell_width, unsigned int cell_height, unsigned int num_cells, bool bold, bool italic, bool rescale, FONTS_DATA_HANDLE fg) { if (!load_glyph(self, glyph_id, FT_LOAD_RENDER)) return false; unsigned int max_width = cell_width * num_cells; @@ -508,7 +508,7 @@ downsample_bitmap(ProcessedBitmap *bm, unsigned int width, unsigned int cell_hei bm->buf = dest; bm->needs_free = true; bm->stride = 4 * width; bm->width = width; bm->rows = cell_height; } -static inline void +static void detect_right_edge(ProcessedBitmap *ans) { ans->right_edge = 0; for (ssize_t x = ans->width - 1; !ans->right_edge && x > -1; x--) { @@ -519,7 +519,7 @@ detect_right_edge(ProcessedBitmap *ans) { } } -static inline bool +static bool render_color_bitmap(Face *self, int glyph_id, ProcessedBitmap *ans, unsigned int cell_width, unsigned int cell_height, unsigned int num_cells, unsigned int baseline UNUSED) { unsigned short best = 0, diff = USHRT_MAX; const short limit = self->face->num_fixed_sizes; @@ -550,7 +550,7 @@ render_color_bitmap(Face *self, int glyph_id, ProcessedBitmap *ans, unsigned int } -static inline void +static void copy_color_bitmap(uint8_t *src, pixel* dest, Region *src_rect, Region *dest_rect, size_t src_stride, size_t dest_stride) { for (size_t sr = src_rect->top, dr = dest_rect->top; sr < src_rect->bottom && dr < dest_rect->bottom; sr++, dr++) { pixel *d = dest + dest_stride * dr; @@ -566,7 +566,7 @@ copy_color_bitmap(uint8_t *src, pixel* dest, Region *src_rect, Region *dest_rect } } -static inline void +static void place_bitmap_in_canvas(pixel *cell, ProcessedBitmap *bm, size_t cell_width, size_t cell_height, float x_offset, float y_offset, size_t baseline, unsigned int glyph_num) { // We want the glyph to be positioned inside the cell based on the bearingX // and bearingY values, making sure that it does not overflow the cell. diff --git a/kitty/gl.c b/kitty/gl.c index b15fe0009..21435bd09 100644 --- a/kitty/gl.c +++ b/kitty/gl.c @@ -226,7 +226,7 @@ unbind_buffer(ssize_t buf_idx) { glBindBuffer(buffers[buf_idx].usage, 0); } -static inline void +static void alloc_buffer(ssize_t idx, GLsizeiptr size, GLenum usage) { Buffer *b = buffers + idx; if (b->size == size) return; @@ -234,13 +234,13 @@ alloc_buffer(ssize_t idx, GLsizeiptr size, GLenum usage) { glBufferData(b->usage, size, NULL, usage); } -static inline void* +static void* map_buffer(ssize_t idx, GLenum access) { void *ans = glMapBuffer(buffers[idx].usage, access); return ans; } -static inline void +static void unmap_buffer(ssize_t idx) { glUnmapBuffer(buffers[idx].usage); } diff --git a/kitty/glfw.c b/kitty/glfw.c index 7f74131a2..37894c580 100644 --- a/kitty/glfw.c +++ b/kitty/glfw.c @@ -49,7 +49,7 @@ request_tick_callback(void) { glfwPostEmptyEvent(); } -static inline void +static void min_size_for_os_window(OSWindow *window, int *min_width, int *min_height) { *min_width = MAX(8u, window->fonts_data->cell_width + 1); *min_height = MAX(8u, window->fonts_data->cell_height + 1); @@ -124,7 +124,7 @@ update_os_window_references() { } } -static inline bool +static bool set_callback_window(GLFWwindow *w) { global_state.callback_os_window = glfwGetWindowUserPointer(w); if (global_state.callback_os_window) return true; @@ -137,7 +137,7 @@ set_callback_window(GLFWwindow *w) { return false; } -static inline bool +static bool is_window_ready_for_callbacks(void) { OSWindow *w = global_state.callback_os_window; if (w->num_tabs == 0) return false; @@ -148,7 +148,7 @@ is_window_ready_for_callbacks(void) { #define WINDOW_CALLBACK(name, fmt, ...) call_boss(name, "K" fmt, global_state.callback_os_window->id, __VA_ARGS__) -static inline void +static void show_mouse_cursor(GLFWwindow *w) { glfwSetInputMode(w, GLFW_CURSOR, GLFW_CURSOR_NORMAL); } @@ -250,7 +250,7 @@ refresh_callback(GLFWwindow *w) { static int mods_at_last_key_or_button_event = 0; -static inline int +static int key_to_modifier(uint32_t key) { switch(key) { case GLFW_FKEY_LEFT_SHIFT: @@ -403,7 +403,7 @@ application_close_requested_callback(int flags) { } } -static inline void get_window_dpi(GLFWwindow *w, double *x, double *y); +static void get_window_dpi(GLFWwindow *w, double *x, double *y); #ifdef __APPLE__ static bool @@ -492,7 +492,7 @@ set_os_window_size(OSWindow *os_window, int x, int y) { glfwSetWindowSize(os_window->handle, x, y); } -static inline void +static void get_window_content_scale(GLFWwindow *w, float *xscale, float *yscale, double *xdpi, double *ydpi) { *xscale = 1; *yscale = 1; if (w) glfwGetWindowContentScale(w, xscale, yscale); @@ -611,7 +611,7 @@ set_titlebar_color(OSWindow *w, color_type color, bool use_system_color) { } } -static inline PyObject* +static PyObject* native_window_handle(GLFWwindow *w) { #ifdef __APPLE__ void *ans = glfwGetCocoaWindow(w); @@ -815,7 +815,7 @@ os_window_update_size_increments(OSWindow *window) { } #ifdef __APPLE__ -static inline bool +static bool window_in_same_cocoa_workspace(void *w, size_t *source_workspaces, size_t source_workspace_count) { static size_t workspaces[64]; size_t workspace_count = cocoa_get_workspace_ids(w, workspaces, arraysz(workspaces)); @@ -827,7 +827,7 @@ window_in_same_cocoa_workspace(void *w, size_t *source_workspaces, size_t source return false; } -static inline void +static void cocoa_focus_last_window(id_type source_window_id, size_t *source_workspaces, size_t source_workspace_count) { id_type highest_focus_number = 0; OSWindow *window_to_focus = NULL; diff --git a/kitty/graphics.c b/kitty/graphics.c index 8949d8802..3df1d7b13 100644 --- a/kitty/graphics.c +++ b/kitty/graphics.c @@ -29,31 +29,31 @@ PyTypeObject GraphicsManager_Type; // caching {{{ #define CACHE_KEY_BUFFER_SIZE 32 -static inline size_t +static size_t cache_key(const ImageAndFrame x, char *key) { return snprintf(key, CACHE_KEY_BUFFER_SIZE, "%llx:%x", x.image_id, x.frame_id); } #define CK(x) key, cache_key(x, key) -static inline bool +static bool add_to_cache(GraphicsManager *self, const ImageAndFrame x, const void *data, const size_t sz) { char key[CACHE_KEY_BUFFER_SIZE]; return add_to_disk_cache(self->disk_cache, CK(x), data, sz); } -static inline bool +static bool remove_from_cache(GraphicsManager *self, const ImageAndFrame x) { char key[CACHE_KEY_BUFFER_SIZE]; return remove_from_disk_cache(self->disk_cache, CK(x)); } -static inline bool +static bool read_from_cache(const GraphicsManager *self, const ImageAndFrame x, void **data, size_t *sz) { char key[CACHE_KEY_BUFFER_SIZE]; return read_from_disk_cache_simple(self->disk_cache, CK(x), data, sz, false); } -static inline size_t +static size_t cache_size(const GraphicsManager *self) { return disk_cache_total_size(self->disk_cache); } #undef CK // }}} @@ -75,13 +75,13 @@ grman_alloc() { return self; } -static inline void +static void free_refs_data(Image *img) { free(img->refs); img->refs = NULL; img->refcnt = 0; img->refcap = 0; } -static inline void +static void free_load_data(LoadData *ld) { free(ld->buf); ld->buf_used = 0; ld->buf_capacity = 0; ld->buf = NULL; if (ld->mapped_file) munmap(ld->mapped_file, ld->mapped_file_sz); @@ -89,7 +89,7 @@ free_load_data(LoadData *ld) { ld->loading_for = (const ImageAndFrame){0}; } -static inline void +static void free_image(GraphicsManager *self, Image *img) { if (img->texture_id) free_texture(&img->texture_id); ImageAndFrame key = { .image_id=img->internal_id, .frame_id = img->root_frame.id }; @@ -121,7 +121,7 @@ dealloc(GraphicsManager* self) { static id_type internal_id_counter = 1; -static inline Image* +static Image* img_by_internal_id(GraphicsManager *self, id_type id) { for (size_t i = 0; i < self->image_count; i++) { if (self->images[i].internal_id == id) return self->images + i; @@ -129,7 +129,7 @@ img_by_internal_id(GraphicsManager *self, id_type id) { return NULL; } -static inline Image* +static Image* img_by_client_id(GraphicsManager *self, uint32_t id) { for (size_t i = 0; i < self->image_count; i++) { if (self->images[i].client_id == id) return self->images + i; @@ -137,7 +137,7 @@ img_by_client_id(GraphicsManager *self, uint32_t id) { return NULL; } -static inline Image* +static Image* img_by_client_number(GraphicsManager *self, uint32_t number) { // get the newest image with the specified number for (size_t i = self->image_count; i-- > 0; ) { @@ -147,14 +147,14 @@ img_by_client_number(GraphicsManager *self, uint32_t number) { } -static inline void +static void remove_image(GraphicsManager *self, size_t idx) { free_image(self, self->images + idx); remove_i_from_array(self->images, idx, self->image_count); self->layers_dirty = true; } -static inline void +static void remove_images(GraphicsManager *self, bool(*predicate)(Image*), id_type skip_image_internal_id) { for (size_t i = self->image_count; i-- > 0;) { Image *img = self->images + i; @@ -173,7 +173,7 @@ trim_predicate(Image *img) { } -static inline void +static void apply_storage_quota(GraphicsManager *self, size_t storage_limit, id_type currently_added_image_internal_id) { // First remove unreferenced images, even if they have an id remove_images(self, trim_predicate, currently_added_image_internal_id); @@ -190,7 +190,7 @@ apply_storage_quota(GraphicsManager *self, size_t storage_limit, id_type current static char command_response[512] = {0}; -static inline void +static void set_command_failed_response(const char *code, const char *fmt, ...) { va_list args; va_start(args, fmt); @@ -203,7 +203,7 @@ set_command_failed_response(const char *code, const char *fmt, ...) { // Decode formats {{{ #define ABRT(code, ...) { set_command_failed_response(#code, __VA_ARGS__); goto err; } -static inline bool +static bool mmap_img_file(GraphicsManager *self, int fd, size_t sz, off_t offset) { if (!sz) { struct stat s; @@ -220,7 +220,7 @@ err: } -static inline const char* +static const char* zlib_strerror(int ret) { #define Z(x) case x: return #x; static char buf[128]; @@ -239,7 +239,7 @@ zlib_strerror(int ret) { #undef Z } -static inline bool +static bool inflate_zlib(LoadData *load_data, uint8_t *buf, size_t bufsz) { bool ok = false; z_stream z; @@ -272,7 +272,7 @@ png_error_handler(const char *code, const char *msg) { set_command_failed_response(code, "%s", msg); } -static inline bool +static bool inflate_png(LoadData *load_data, uint8_t *buf, size_t bufsz) { png_read_data d = {.err_handler=png_error_handler}; inflate_png_inner(&d, buf, bufsz); @@ -342,7 +342,7 @@ png_path_to_bitmap(const char* path, uint8_t** data, unsigned int* width, unsign } -static inline Image* +static Image* find_or_create_image(GraphicsManager *self, uint32_t id, bool *existing) { if (id) { for (size_t i = 0; i < self->image_count; i++) { @@ -359,7 +359,7 @@ find_or_create_image(GraphicsManager *self, uint32_t id, bool *existing) { return ans; } -static inline uint32_t +static uint32_t get_free_client_id(const GraphicsManager *self) { if (!self->image_count) return 1; uint32_t *client_ids = malloc(sizeof(uint32_t) * self->image_count); @@ -608,7 +608,7 @@ handle_add_command(GraphicsManager *self, const GraphicsCommand *g, const uint8_ #undef MAX_DATA_SZ } -static inline const char* +static const char* finish_command_response(const GraphicsCommand *g, bool data_loaded) { static char rbuf[sizeof(command_response)/sizeof(command_response[0]) + 128]; bool is_ok_response = !command_response[0]; @@ -638,7 +638,7 @@ finish_command_response(const GraphicsCommand *g, bool data_loaded) { // Displaying images {{{ -static inline void +static void update_src_rect(ImageRef *ref, Image *img) { // The src rect in OpenGL co-ords [0, 1] with origin at top-left corner of image ref->src_rect.left = (float)ref->src_x / (float)img->width; @@ -647,7 +647,7 @@ update_src_rect(ImageRef *ref, Image *img) { ref->src_rect.bottom = (float)(ref->src_y + ref->src_height) / (float)img->height; } -static inline void +static void update_dest_rect(ImageRef *ref, uint32_t num_cols, uint32_t num_rows, CellPixelSize cell) { uint32_t t; if (num_cols == 0) { @@ -708,7 +708,7 @@ handle_put_command(GraphicsManager *self, const GraphicsCommand *g, Cursor *c, b return img->client_id; } -static inline void +static void set_vertex_data(ImageRenderData *rd, const ImageRef *ref, const ImageRect *dest_rect) { #define R(n, a, b) rd->vertices[n*4] = ref->src_rect.a; rd->vertices[n*4 + 1] = ref->src_rect.b; rd->vertices[n*4 + 2] = dest_rect->a; rd->vertices[n*4 + 3] = dest_rect->b; R(0, right, top); R(1, right, bottom); R(2, left, bottom); R(3, left, top); @@ -804,13 +804,13 @@ grman_update_layers(GraphicsManager *self, unsigned int scrolled_by, float scree // Animation {{{ #define DEFAULT_GAP 40 -static inline Frame* +static Frame* current_frame(Image *img) { if (img->current_frame_index > img->extra_framecnt) return NULL; return img->current_frame_index ? img->extra_frames + img->current_frame_index - 1 : &img->root_frame; } -static inline Frame* +static Frame* frame_for_id(Image *img, const uint32_t frame_id) { if (img->root_frame.id == frame_id) return &img->root_frame; for (unsigned i = 0; i < img->extra_framecnt; i++) { @@ -832,7 +832,7 @@ frame_for_number(Image *img, const uint32_t frame_number) { } } -static inline void +static void change_gap(Image *img, Frame *f, int32_t gap) { uint32_t prev_gap = f->gap; f->gap = MAX(0, gap); @@ -845,14 +845,14 @@ typedef struct { bool is_4byte_aligned, is_opaque; } CoalescedFrameData; -static inline void +static void blend_on_opaque(uint8_t *under_px, const uint8_t *over_px) { const float alpha = (float)over_px[3] / 255.f; const float alpha_op = 1.f - alpha; for (unsigned i = 0; i < 3; i++) under_px[i] = (uint8_t)(over_px[i] * alpha + under_px[i] * alpha_op); } -static inline void +static void alpha_blend(uint8_t *dest_px, const uint8_t *src_px) { if (src_px[3]) { const float dest_a = (float)dest_px[3] / 255.f, src_a = (float)src_px[3] / 255.f; @@ -1255,7 +1255,7 @@ handle_animation_control_command(GraphicsManager *self, bool *is_dirty, const Gr } } -static inline bool +static bool image_is_animatable(const Image *img) { return img->animation_state != ANIMATION_STOPPED && img->extra_framecnt && img->is_drawn && img->animation_duration && ( !img->max_loops || img->current_loop < img->max_loops); @@ -1368,7 +1368,7 @@ handle_compose_command(GraphicsManager *self, bool *is_dirty, const GraphicsComm // Image lifetime/scrolling {{{ -static inline void +static void filter_refs(GraphicsManager *self, const void* data, bool free_images, bool (*filter_func)(const ImageRef*, Image*, const void*, CellPixelSize), CellPixelSize cell, bool only_first_image) { bool matched = false; for (size_t i = self->image_count; i-- > 0;) { @@ -1403,24 +1403,24 @@ modify_refs(GraphicsManager *self, const void* data, bool (*filter_func)(ImageRe } -static inline bool +static bool scroll_filter_func(ImageRef *ref, Image UNUSED *img, const void *data, CellPixelSize cell UNUSED) { ScrollData *d = (ScrollData*)data; ref->start_row += d->amt; return ref->start_row + (int32_t)ref->effective_num_rows <= d->limit; } -static inline bool +static bool ref_within_region(const ImageRef *ref, index_type margin_top, index_type margin_bottom) { return ref->start_row >= (int32_t)margin_top && ref->start_row + ref->effective_num_rows <= margin_bottom; } -static inline bool +static bool ref_outside_region(const ImageRef *ref, index_type margin_top, index_type margin_bottom) { return ref->start_row + ref->effective_num_rows <= margin_top || ref->start_row > (int32_t)margin_bottom; } -static inline bool +static bool scroll_filter_margins_func(ImageRef* ref, Image* img, const void* data, CellPixelSize cell) { ScrollData *d = (ScrollData*)data; if (ref_within_region(ref, d->margin_top, d->margin_bottom)) { @@ -1459,12 +1459,12 @@ grman_scroll_images(GraphicsManager *self, const ScrollData *data, CellPixelSize } } -static inline bool +static bool clear_filter_func(const ImageRef *ref, Image UNUSED *img, const void UNUSED *data, CellPixelSize cell UNUSED) { return ref->start_row + (int32_t)ref->effective_num_rows > 0; } -static inline bool +static bool clear_all_filter_func(const ImageRef *ref UNUSED, Image UNUSED *img, const void UNUSED *data, CellPixelSize cell UNUSED) { return true; } @@ -1474,14 +1474,14 @@ grman_clear(GraphicsManager *self, bool all, CellPixelSize cell) { filter_refs(self, NULL, true, all ? clear_all_filter_func : clear_filter_func, cell, false); } -static inline bool +static bool id_filter_func(const ImageRef *ref, Image *img, const void *data, CellPixelSize cell UNUSED) { const GraphicsCommand *g = data; if (g->id && img->client_id == g->id) return !g->placement_id || ref->client_id == g->placement_id; return false; } -static inline bool +static bool number_filter_func(const ImageRef *ref, Image *img, const void *data, CellPixelSize cell UNUSED) { const GraphicsCommand *g = data; if (g->image_number && img->client_number == g->image_number) return !g->placement_id || ref->client_id == g->placement_id; @@ -1489,31 +1489,31 @@ number_filter_func(const ImageRef *ref, Image *img, const void *data, CellPixelS } -static inline bool +static bool x_filter_func(const ImageRef *ref, Image UNUSED *img, const void *data, CellPixelSize cell UNUSED) { const GraphicsCommand *g = data; return ref->start_column <= (int32_t)g->x_offset - 1 && ((int32_t)g->x_offset - 1) < ((int32_t)(ref->start_column + ref->effective_num_cols)); } -static inline bool +static bool y_filter_func(const ImageRef *ref, Image UNUSED *img, const void *data, CellPixelSize cell UNUSED) { const GraphicsCommand *g = data; return ref->start_row <= (int32_t)g->y_offset - 1 && ((int32_t)(g->y_offset - 1 < ref->start_row + ref->effective_num_rows)); } -static inline bool +static bool z_filter_func(const ImageRef *ref, Image UNUSED *img, const void *data, CellPixelSize cell UNUSED) { const GraphicsCommand *g = data; return ref->z_index == g->z_index; } -static inline bool +static bool point_filter_func(const ImageRef *ref, Image *img, const void *data, CellPixelSize cell) { return x_filter_func(ref, img, data, cell) && y_filter_func(ref, img, data, cell); } -static inline bool +static bool point3d_filter_func(const ImageRef *ref, Image *img, const void *data, CellPixelSize cell) { return z_filter_func(ref, img, data, cell) && point_filter_func(ref, img, data, cell); } @@ -1682,7 +1682,7 @@ new(PyTypeObject UNUSED *type, PyObject UNUSED *args, PyObject UNUSED *kwds) { return ans; } -static inline PyObject* +static PyObject* image_as_dict(GraphicsManager *self, Image *img) { #define U(x) #x, (unsigned int)(img->x) #define B(x) #x, img->x ? Py_True : Py_False diff --git a/kitty/history.c b/kitty/history.c index ef8fd9541..d9652b845 100644 --- a/kitty/history.c +++ b/kitty/history.c @@ -14,7 +14,7 @@ extern PyTypeObject Line_Type; #define SEGMENT_SIZE 2048 -static inline void +static void add_segment(HistoryBuf *self) { self->num_segments += 1; self->segments = realloc(self->segments, sizeof(HistoryBufSegment) * self->num_segments); @@ -28,7 +28,7 @@ add_segment(HistoryBuf *self) { s->line_attrs = (line_attrs_type*)(((uint8_t*)s->gpu_cells) + gpu_cells_size); } -static inline index_type +static index_type segment_for(HistoryBuf *self, index_type y) { index_type seg_num = y / SEGMENT_SIZE; while (UNLIKELY(seg_num >= self->num_segments && SEGMENT_SIZE * self->num_segments < self->ynum)) add_segment(self); @@ -42,23 +42,23 @@ segment_for(HistoryBuf *self, index_type y) { return self->segments[seg_num].which + y * stride; \ } -static inline CPUCell* +static CPUCell* cpu_lineptr(HistoryBuf *self, index_type y) { seg_ptr(cpu_cells, self->xnum); } -static inline GPUCell* +static GPUCell* gpu_lineptr(HistoryBuf *self, index_type y) { seg_ptr(gpu_cells, self->xnum); } -static inline line_attrs_type* +static line_attrs_type* attrptr(HistoryBuf *self, index_type y) { seg_ptr(line_attrs, 1); } -static inline PagerHistoryBuf* +static PagerHistoryBuf* alloc_pagerhist(size_t pagerhist_sz) { PagerHistoryBuf *ph; if (!pagerhist_sz) return NULL; @@ -71,14 +71,14 @@ alloc_pagerhist(size_t pagerhist_sz) { return ph; } -static inline void +static void free_pagerhist(HistoryBuf *self) { if (self->pagerhist && self->pagerhist->ringbuf) ringbuf_free((ringbuf_t*)&self->pagerhist->ringbuf); free(self->pagerhist); self->pagerhist = NULL; } -static inline bool +static bool pagerhist_extend(PagerHistoryBuf *ph, size_t minsz) { size_t buffer_size = ringbuf_capacity(ph->ringbuf); if (buffer_size >= ph->maximum_size) return false; @@ -92,7 +92,7 @@ pagerhist_extend(PagerHistoryBuf *ph, size_t minsz) { return true; } -static inline void +static void pagerhist_clear(HistoryBuf *self) { if (self->pagerhist && self->pagerhist->ringbuf) ringbuf_reset(self->pagerhist->ringbuf); } @@ -133,7 +133,7 @@ dealloc(HistoryBuf* self) { Py_TYPE(self)->tp_free((PyObject*)self); } -static inline index_type +static index_type index_of(HistoryBuf *self, index_type lnum) { // The index (buffer position) of the line with line number lnum // This is reverse indexing, i.e. lnum = 0 corresponds to the *last* line in the buffer. @@ -142,7 +142,7 @@ index_of(HistoryBuf *self, index_type lnum) { return (self->start_of_data + idx) % self->ynum; } -static inline void +static void init_line(HistoryBuf *self, index_type num, Line *l) { // Initialize the line l, setting its pointer to the offsets for the line at index (buffer position) num l->cpu_cells = cpu_lineptr(self, num); @@ -180,7 +180,7 @@ historybuf_clear(HistoryBuf *self) { self->start_of_data = 0; } -static inline bool +static bool pagerhist_write_bytes(PagerHistoryBuf *ph, const uint8_t *buf, size_t sz) { if (sz > ph->maximum_size) return false; if (!sz) return true; @@ -190,7 +190,7 @@ pagerhist_write_bytes(PagerHistoryBuf *ph, const uint8_t *buf, size_t sz) { return true; } -static inline bool +static bool pagerhist_ensure_start_is_valid_utf8(PagerHistoryBuf *ph) { uint8_t scratch[8]; size_t num = ringbuf_memcpy_from(scratch, ph->ringbuf, arraysz(scratch)); @@ -210,7 +210,7 @@ pagerhist_ensure_start_is_valid_utf8(PagerHistoryBuf *ph) { return false; } -static inline bool +static bool pagerhist_write_ucs4(PagerHistoryBuf *ph, const Py_UCS4 *buf, size_t sz) { uint8_t scratch[4]; for (size_t i = 0; i < sz; i++) { @@ -220,7 +220,7 @@ pagerhist_write_ucs4(PagerHistoryBuf *ph, const Py_UCS4 *buf, size_t sz) { return true; } -static inline void +static void pagerhist_push(HistoryBuf *self, ANSIBuf *as_ansi_buf) { PagerHistoryBuf *ph = self->pagerhist; if (!ph) return; @@ -233,7 +233,7 @@ pagerhist_push(HistoryBuf *self, ANSIBuf *as_ansi_buf) { if (pagerhist_write_ucs4(ph, as_ansi_buf->buf, as_ansi_buf->len)) pagerhist_write_bytes(ph, (const uint8_t*)"\r", 1); } -static inline index_type +static index_type historybuf_push(HistoryBuf *self, ANSIBuf *as_ansi_buf) { index_type idx = (self->start_of_data + self->count) % self->ynum; init_line(self, idx, self->line); @@ -327,10 +327,10 @@ end: Py_RETURN_NONE; } -static inline Line* +static Line* get_line(HistoryBuf *self, index_type y, Line *l) { init_line(self, index_of(self, self->count - y - 1), l); return l; } -static inline char_type +static char_type pagerhist_remove_char(PagerHistoryBuf *ph, unsigned *count, uint8_t record[8]) { uint32_t codep; UTF8State state = UTF8_ACCEPT; *count = 0; diff --git a/kitty/key_encoding.c b/kitty/key_encoding.c index bebc0ee2e..251f67f8f 100644 --- a/kitty/key_encoding.c +++ b/kitty/key_encoding.c @@ -46,7 +46,7 @@ is_modifier_key(const uint32_t key) { END_ALLOW_CASE_RANGE } -static inline void +static void convert_glfw_mods(int mods, KeyEvent *ev, const unsigned key_encoding_flags) { if (!key_encoding_flags) mods &= ~GLFW_LOCK_MASK; ev->mods.alt = (mods & GLFW_MOD_ALT) > 0, ev->mods.ctrl = (mods & GLFW_MOD_CONTROL) > 0, ev->mods.shift = (mods & GLFW_MOD_SHIFT) > 0, ev->mods.super = (mods & GLFW_MOD_SUPER) > 0, ev->mods.hyper = (mods & GLFW_MOD_HYPER) > 0, ev->mods.meta = (mods & GLFW_MOD_META) > 0; @@ -63,7 +63,7 @@ convert_glfw_mods(int mods, KeyEvent *ev, const unsigned key_encoding_flags) { } -static inline void +static void init_encoding_data(EncodingData *ans, const KeyEvent *ev) { ans->add_actions = ev->report_all_event_types && ev->action != PRESS; ans->has_mods = ev->mods.encoded[0] && ( ev->mods.encoded[0] != '1' || ev->mods.encoded[1] ); @@ -76,7 +76,7 @@ init_encoding_data(EncodingData *ans, const KeyEvent *ev) { memcpy(ans->encoded_mods, ev->mods.encoded, sizeof(ans->encoded_mods)); } -static inline int +static int serialize(const EncodingData *data, char *output, const char csi_trailer) { int pos = 0; bool second_field_not_empty = data->has_mods || data->add_actions; @@ -113,7 +113,7 @@ serialize(const EncodingData *data, char *output, const char csi_trailer) { return pos; } -static inline uint32_t +static uint32_t convert_kp_key_to_normal_key(uint32_t key_number) { switch(key_number) { #define S(x) case GLFW_FKEY_KP_##x: key_number = GLFW_FKEY_##x; break; @@ -329,7 +329,7 @@ encode_printable_ascii_key_legacy(const KeyEvent *ev, char *output) { return 0; } -static inline bool +static bool is_legacy_ascii_key(uint32_t key) { START_ALLOW_CASE_RANGE switch (key) { @@ -408,7 +408,7 @@ encode_key(const KeyEvent *ev, char *output) { return serialize(&ed, output, 'u'); } -static inline bool +static bool startswith_ascii_control_char(const char *p) { if (!p || !*p) return true; uint32_t codep; UTF8State state = UTF8_ACCEPT; diff --git a/kitty/keys.c b/kitty/keys.c index 1ef0eb89d..04ccc2034 100644 --- a/kitty/keys.c +++ b/kitty/keys.c @@ -20,7 +20,7 @@ typedef struct { PyObject *text; } PyKeyEvent; -static inline PyObject* convert_glfw_key_event_to_python(const GLFWkeyevent *ev); +static PyObject* convert_glfw_key_event_to_python(const GLFWkeyevent *ev); static PyObject* new(PyTypeObject *type UNUSED, PyObject *args, PyObject *kw) { @@ -58,7 +58,7 @@ PyTypeObject PyKeyEvent_Type = { .tp_new = new, }; -static inline PyObject* +static PyObject* convert_glfw_key_event_to_python(const GLFWkeyevent *ev) { PyKeyEvent *self = (PyKeyEvent*)PyKeyEvent_Type.tp_alloc(&PyKeyEvent_Type, 0); if (!self) return NULL; @@ -71,7 +71,7 @@ convert_glfw_key_event_to_python(const GLFWkeyevent *ev) { } // }}} -static inline Window* +static Window* active_window(void) { Tab *t = global_state.callback_os_window->tabs + global_state.callback_os_window->active_tab; Window *w = t->windows + t->active_window; @@ -79,7 +79,7 @@ active_window(void) { return NULL; } -static inline void +static void update_ime_position(OSWindow *os_window, Window* w, Screen *screen) { unsigned int cell_width = os_window->fonts_data->cell_width, cell_height = os_window->fonts_data->cell_height; unsigned int left = w->geometry.left, top = w->geometry.top; diff --git a/kitty/kittens.c b/kitty/kittens.c index 0596d13de..be54d80ba 100644 --- a/kitty/kittens.c +++ b/kitty/kittens.c @@ -11,7 +11,7 @@ #define CMD_BUF_SZ 2048 -static inline bool +static bool append_buf(char buf[CMD_BUF_SZ], size_t *pos, PyObject *ans) { if (*pos) { PyObject *bytes = PyBytes_FromStringAndSize(buf, *pos); @@ -24,7 +24,7 @@ append_buf(char buf[CMD_BUF_SZ], size_t *pos, PyObject *ans) { return true; } -static inline bool +static bool add_char(char buf[CMD_BUF_SZ], size_t *pos, char ch, PyObject *ans) { if (*pos >= CMD_BUF_SZ) { if (!append_buf(buf, pos, ans)) return false; @@ -34,7 +34,7 @@ add_char(char buf[CMD_BUF_SZ], size_t *pos, char ch, PyObject *ans) { return true; } -static inline bool +static bool read_response(int fd, monotonic_t timeout, PyObject *ans) { static char buf[CMD_BUF_SZ]; size_t pos = 0; diff --git a/kitty/line-buf.c b/kitty/line-buf.c index 863a67868..61c1700ec 100644 --- a/kitty/line-buf.c +++ b/kitty/line-buf.c @@ -12,17 +12,17 @@ extern PyTypeObject Line_Type; extern PyTypeObject HistoryBuf_Type; -static inline CPUCell* +static CPUCell* cpu_lineptr(LineBuf *linebuf, index_type y) { return linebuf->cpu_cell_buf + y * linebuf->xnum; } -static inline GPUCell* +static GPUCell* gpu_lineptr(LineBuf *linebuf, index_type y) { return linebuf->gpu_cell_buf + y * linebuf->xnum; } -static inline void +static void clear_chars_to(LineBuf* linebuf, index_type y, char_type ch) { clear_chars_in_line(cpu_lineptr(linebuf, y), gpu_lineptr(linebuf, y), linebuf->xnum, ch); } @@ -118,7 +118,7 @@ dealloc(LineBuf* self) { Py_TYPE(self)->tp_free((PyObject*)self); } -static inline void +static void init_line(LineBuf *lb, Line *l, index_type ynum) { l->cpu_cells = cpu_lineptr(lb, ynum); l->gpu_cells = gpu_lineptr(lb, ynum); @@ -193,7 +193,7 @@ dirty_lines(LineBuf *self, PyObject *a UNUSED) { return ans; } -static inline bool +static bool allocate_line_storage(Line *line, bool initialize) { if (initialize) { line->cpu_cells = PyMem_Calloc(line->xnum, sizeof(CPUCell)); @@ -209,7 +209,7 @@ allocate_line_storage(Line *line, bool initialize) { return true; } -static inline PyObject* +static PyObject* create_line_copy_inner(LineBuf* self, index_type y) { Line src, *line; line = alloc_line(); @@ -247,7 +247,7 @@ copy_line_to(LineBuf *self, PyObject *args) { Py_RETURN_NONE; } -static inline void +static void clear_line_(Line *l, index_type xnum) { zero_at_ptr_count(l->cpu_cells, xnum); zero_at_ptr_count(l->gpu_cells, xnum); @@ -439,7 +439,7 @@ end: Py_RETURN_NONE; } -static inline Line* +static Line* get_line(void *x, int y) { LineBuf *self = (LineBuf*)x; linebuf_init_line(self, MAX(0, y)); diff --git a/kitty/line.c b/kitty/line.c index 06274bee3..97fe76193 100644 --- a/kitty/line.c +++ b/kitty/line.c @@ -49,7 +49,7 @@ cell_text(CPUCell *cell) { // URL detection {{{ -static inline index_type +static index_type find_colon_slash(Line *self, index_type x, index_type limit) { // Find :// at or before x index_type pos = MIN(x, self->xnum - 1); @@ -84,7 +84,7 @@ find_colon_slash(Line *self, index_type x, index_type limit) { return 0; } -static inline bool +static bool prefix_matches(Line *self, index_type at, const char_type* prefix, index_type prefix_len) { if (prefix_len > at) return false; index_type p, i; @@ -94,7 +94,7 @@ prefix_matches(Line *self, index_type at, const char_type* prefix, index_type pr return i == prefix_len; } -static inline bool +static bool has_url_prefix_at(Line *self, index_type at, index_type min_prefix_len, index_type *ans) { for (size_t i = 0; i < OPT(url_prefixes.num); i++) { index_type prefix_len = OPT(url_prefixes.values[i].len); @@ -106,7 +106,7 @@ has_url_prefix_at(Line *self, index_type at, index_type min_prefix_len, index_ty #define MIN_URL_LEN 5 -static inline bool +static bool has_url_beyond(Line *self, index_type x) { for (index_type i = x; i < MIN(x + MIN_URL_LEN + 3, self->xnum); i++) { if (!is_url_char(self->cpu_cells[i].ch)) return false; @@ -268,7 +268,7 @@ sprite_at(Line* self, PyObject *x) { return Py_BuildValue("HHH", c->sprite_x, c->sprite_y, c->sprite_z); } -static inline void +static void write_sgr(const char *val, ANSIBuf *output) { #define W(c) output->buf[output->len++] = c W(0x1b); W('['); @@ -277,7 +277,7 @@ write_sgr(const char *val, ANSIBuf *output) { #undef W } -static inline void +static void write_hyperlink(hyperlink_id_type hid, ANSIBuf *output) { #define W(c) output->buf[output->len++] = c const char *key = hid ? get_hyperlink_for_id(output->hyperlink_pool, hid, false) : NULL; @@ -636,7 +636,7 @@ set_attribute(Line *self, PyObject *args) { Py_RETURN_NONE; } -static inline int +static int color_as_sgr(char *buf, size_t sz, unsigned long val, unsigned simple_code, unsigned aix_code, unsigned complex_code) { switch(val & 0xff) { case 1: @@ -652,7 +652,7 @@ color_as_sgr(char *buf, size_t sz, unsigned long val, unsigned simple_code, unsi } } -static inline const char* +static const char* decoration_as_sgr(uint8_t decoration) { switch(decoration) { case 1: return "4;"; @@ -722,7 +722,7 @@ line_has_mark(Line *line, attrs_type mark) { return false; } -static inline void +static void report_marker_error(PyObject *marker) { if (!PyObject_HasAttrString(marker, "error_reported")) { PyErr_Print(); @@ -730,7 +730,7 @@ report_marker_error(PyObject *marker) { } else PyErr_Clear(); } -static inline void +static void apply_mark(Line *line, const attrs_type mark, index_type *cell_pos, unsigned int *match_pos) { #define MARK { line->gpu_cells[x].attrs &= ATTRS_MASK_WITHOUT_MARK; line->gpu_cells[x].attrs |= mark; } index_type x = *cell_pos; @@ -757,7 +757,7 @@ apply_mark(Line *line, const attrs_type mark, index_type *cell_pos, unsigned int #undef MARK } -static inline void +static void apply_marker(PyObject *marker, Line *line, const PyObject *text) { unsigned int l=0, r=0, col=0, match_pos=0; PyObject *pl = PyLong_FromVoidPtr(&l), *pr = PyLong_FromVoidPtr(&r), *pcol = PyLong_FromVoidPtr(&col); diff --git a/kitty/macos_process_info.c b/kitty/macos_process_info.c index e93750cd2..341556201 100644 --- a/kitty/macos_process_info.c +++ b/kitty/macos_process_info.c @@ -23,7 +23,7 @@ cwd_of_process(PyObject *self UNUSED, PyObject *pid_) { } // Read the maximum argument size for processes -static inline int +static int get_argmax() { int argmax; int mib[] = { CTL_KERN, KERN_ARGMAX }; diff --git a/kitty/mouse.c b/kitty/mouse.c index 0bbbc6a98..e10ba54ee 100644 --- a/kitty/mouse.c +++ b/kitty/mouse.c @@ -30,7 +30,7 @@ typedef enum MouseActions { PRESS, RELEASE, DRAG, MOVE } MouseAction; #define EXTRA_BUTTON_INDICATOR (1 << 7) -static inline unsigned int +static unsigned int button_map(int button) { switch(button) { case GLFW_MOUSE_BUTTON_LEFT: @@ -50,7 +50,7 @@ button_map(int button) { } } -static inline unsigned int +static unsigned int encode_button(unsigned int button) { if (button >= 8 && button <= 11) { return (button - 8) | EXTRA_BUTTON_INDICATOR; @@ -65,7 +65,7 @@ encode_button(unsigned int button) { static char mouse_event_buf[64]; -static inline int +static int encode_mouse_event_impl(unsigned int x, unsigned int y, int mouse_tracking_protocol, int button, MouseAction action, int mods) { unsigned int cb = 0; if (action == MOVE) { @@ -161,33 +161,33 @@ dispatch_mouse_event(Window *w, int button, int count, int modifiers, bool grabb return handled; } -static inline unsigned int +static unsigned int window_left(Window *w) { return w->geometry.left - w->padding.left; } -static inline unsigned int +static unsigned int window_right(Window *w) { return w->geometry.right + w->padding.right; } -static inline unsigned int +static unsigned int window_top(Window *w) { return w->geometry.top - w->padding.top; } -static inline unsigned int +static unsigned int window_bottom(Window *w) { return w->geometry.bottom + w->padding.bottom; } -static inline bool +static bool contains_mouse(Window *w) { double x = global_state.callback_os_window->mouse_x, y = global_state.callback_os_window->mouse_y; return (w->visible && window_left(w) <= x && x <= window_right(w) && window_top(w) <= y && y <= window_bottom(w)); } -static inline double +static double distance_to_window(Window *w) { double x = global_state.callback_os_window->mouse_x, y = global_state.callback_os_window->mouse_y; double cx = (window_left(w) + window_right(w)) / 2.0; @@ -197,7 +197,7 @@ distance_to_window(Window *w) { static bool clamp_to_window = false; -static inline bool +static bool cell_for_pos(Window *w, unsigned int *x, unsigned int *y, bool *in_left_half_of_cell, OSWindow *os_window) { WindowGeometry *g = &w->geometry; Screen *screen = w->render_data.screen; @@ -232,9 +232,9 @@ cell_for_pos(Window *w, unsigned int *x, unsigned int *y, bool *in_left_half_of_ return false; } -#define HANDLER(name) static inline void name(Window UNUSED *w, int UNUSED button, int UNUSED modifiers, unsigned int UNUSED window_idx) +#define HANDLER(name) static void name(Window UNUSED *w, int UNUSED button, int UNUSED modifiers, unsigned int UNUSED window_idx) -static inline void +static void set_mouse_cursor_when_dragging(void) { if (mouse_cursor_shape != OPT(pointer_shape_when_dragging)) { mouse_cursor_shape = OPT(pointer_shape_when_dragging); @@ -242,7 +242,7 @@ set_mouse_cursor_when_dragging(void) { } } -static inline void +static void update_drag(Window *w) { Screen *screen = w->render_data.screen; if (screen && screen->selections.in_progress) { @@ -251,7 +251,7 @@ update_drag(Window *w) { set_mouse_cursor_when_dragging(); } -static inline bool +static bool do_drag_scroll(Window *w, bool upwards) { Screen *screen = w->render_data.screen; if (screen->linebuf == screen->main_linebuf) { @@ -280,7 +280,7 @@ drag_scroll(Window *w, OSWindow *frame) { return false; } -static inline void +static void extend_selection(Window *w, bool ended, bool extend_nearest) { Screen *screen = w->render_data.screen; if (screen_has_selection(screen)) { @@ -289,12 +289,12 @@ extend_selection(Window *w, bool ended, bool extend_nearest) { } } -static inline void +static void set_mouse_cursor_for_screen(Screen *screen) { mouse_cursor_shape = screen->modes.mouse_tracking_mode == NO_TRACKING ? OPT(default_pointer_shape): OPT(pointer_shape_when_grabbed); } -static inline void +static void handle_mouse_movement_in_kitty(Window *w, int button, bool mouse_cell_changed) { Screen *screen = w->render_data.screen; if (screen->selections.in_progress && (button == global_state.active_drag_button)) { @@ -343,12 +343,12 @@ HANDLER(handle_move_event) { } } -static inline double +static double distance(double x1, double y1, double x2, double y2) { return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); } -static inline void +static void clear_click_queue(Window *w, int button) { if (0 <= button && button <= (ssize_t)arraysz(w->click_queues)) w->click_queues[button].length = 0; } @@ -467,7 +467,7 @@ HANDLER(handle_button_event) { else add_press(w, button, modifiers); } -static inline int +static int currently_pressed_button(void) { for (int i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++) { if (global_state.callback_os_window->mouse_button_pressed[i]) return i; @@ -485,7 +485,7 @@ HANDLER(handle_event) { } } -static inline void +static void handle_tab_bar_mouse(int button, int UNUSED modifiers) { static monotonic_t last_click_at = 0; if (button != GLFW_MOUSE_BUTTON_LEFT || !global_state.callback_os_window->mouse_button_pressed[button]) return; @@ -495,7 +495,7 @@ handle_tab_bar_mouse(int button, int UNUSED modifiers) { call_boss(activate_tab_at, "KdO", global_state.callback_os_window->id, global_state.callback_os_window->mouse_x, is_double ? Py_True : Py_False); } -static inline bool +static bool mouse_in_region(Region *r) { if (r->left == r->right) return false; if (global_state.callback_os_window->mouse_y < r->top || global_state.callback_os_window->mouse_y > r->bottom) return false; @@ -503,7 +503,7 @@ mouse_in_region(Region *r) { return true; } -static inline Window* +static Window* window_for_id(id_type window_id) { Tab *t = global_state.callback_os_window->tabs + global_state.callback_os_window->active_tab; for (unsigned int i = 0; i < t->num_windows; i++) { @@ -513,7 +513,7 @@ window_for_id(id_type window_id) { return NULL; } -static inline Window* +static Window* window_for_event(unsigned int *window_idx, bool *in_tab_bar) { Region central, tab_bar; os_window_regions(global_state.callback_os_window, ¢ral, &tab_bar); @@ -530,7 +530,7 @@ window_for_event(unsigned int *window_idx, bool *in_tab_bar) { return NULL; } -static inline Window* +static Window* closest_window_for_event(unsigned int *window_idx) { Window *ans = NULL; double closest_distance = UINT_MAX; diff --git a/kitty/parser.c b/kitty/parser.c index d506a2f68..f14d703e3 100644 --- a/kitty/parser.c +++ b/kitty/parser.c @@ -23,7 +23,7 @@ static const uint64_t pow_10_array[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 10000000000 }; -static inline int64_t +static int64_t utoi(const uint32_t *buf, unsigned int sz) { int64_t ans = 0; const uint32_t *p = buf; @@ -45,7 +45,7 @@ utoi(const uint32_t *buf, unsigned int sz) { } -static inline const char* +static const char* utf8(char_type codepoint) { if (!codepoint) return ""; static char buf[8]; @@ -313,7 +313,7 @@ dispatch_esc_mode_char(Screen *screen, uint32_t ch, PyObject DUMP_UNUSED *dump_c // OSC mode {{{ -static inline bool +static bool parse_osc_8(char *buf, char **id, char **url) { char *boundary = strstr(buf, ";"); if (boundary == NULL) return false; @@ -331,7 +331,7 @@ parse_osc_8(char *buf, char **id, char **url) { return true; } -static inline void +static void dispatch_hyperlink(Screen *screen, size_t pos, size_t size, PyObject DUMP_UNUSED *dump_callback) { // since the spec says only ASCII printable chars are allowed in OSC 8, we // can just convert to char* directly @@ -481,14 +481,14 @@ dispatch_osc(Screen *screen, PyObject DUMP_UNUSED *dump_callback) { case '/': -static inline void +static void screen_cursor_up2(Screen *s, unsigned int count) { screen_cursor_up(s, count, false, -1); } -static inline void +static void screen_cursor_back1(Screen *s, unsigned int count) { screen_cursor_back(s, count, -1); } -static inline void +static void screen_tabn(Screen *s, unsigned int count) { for (index_type i=0; i < MAX(1u, count); i++) screen_tab(s); } -static inline const char* +static const char* repr_csi_params(int *params, unsigned int num_params) { if (!num_params) return ""; static char buf[256]; @@ -633,7 +633,7 @@ parse_sgr(Screen *screen, uint32_t *buf, unsigned int num, int *params, PyObject #undef SEND_SGR } -static inline unsigned int +static unsigned int parse_region(Region *r, uint32_t *buf, unsigned int num) { unsigned int i, start, num_params = 0; int params[8] = {0}; @@ -668,7 +668,7 @@ parse_region(Region *r, uint32_t *buf, unsigned int num) { return i; } -static inline const char* +static const char* csi_letter(unsigned code) { static char buf[8]; if (33 <= code && code <= 126) snprintf(buf, sizeof(buf), "%c", code); @@ -676,7 +676,7 @@ csi_letter(unsigned code) { return buf; } -static inline void +static void dispatch_csi(Screen *screen, PyObject DUMP_UNUSED *dump_callback) { #define AT_MOST_ONE_PARAMETER { \ if (num_params > 1) { \ @@ -996,7 +996,7 @@ dispatch_csi(Screen *screen, PyObject DUMP_UNUSED *dump_callback) { // DCS mode {{{ -static inline bool +static bool startswith(const uint32_t *string, size_t sz, const char *prefix) { size_t l = strlen(prefix); if (sz < l) return false; @@ -1008,7 +1008,7 @@ startswith(const uint32_t *string, size_t sz, const char *prefix) { #define PENDING_MODE_CHAR '=' -static inline void +static void dispatch_dcs(Screen *screen, PyObject DUMP_UNUSED *dump_callback) { if (screen->parser_buf_pos < 2) return; switch(screen->parser_buf[0]) { @@ -1077,7 +1077,7 @@ dispatch_dcs(Screen *screen, PyObject DUMP_UNUSED *dump_callback) { #include "parse-graphics-command.h" -static inline void +static void dispatch_apc(Screen *screen, PyObject DUMP_UNUSED *dump_callback) { if (screen->parser_buf_pos < 2) return; switch(screen->parser_buf[0]) { @@ -1093,7 +1093,7 @@ dispatch_apc(Screen *screen, PyObject DUMP_UNUSED *dump_callback) { // }}} // PM mode {{{ -static inline void +static void dispatch_pm(Screen *screen, PyObject DUMP_UNUSED *dump_callback) { if (screen->parser_buf_pos < 2) return; switch(screen->parser_buf[0]) { @@ -1144,7 +1144,7 @@ accumulate_osc(Screen *screen, uint32_t ch, PyObject DUMP_UNUSED *dump_callback, return false; } -static inline bool +static bool accumulate_dcs(Screen *screen, uint32_t ch, PyObject DUMP_UNUSED *dump_callback) { switch(ch) { case ST: @@ -1174,7 +1174,7 @@ END_ALLOW_CASE_RANGE } -static inline bool +static bool accumulate_oth(Screen *screen, uint32_t ch, PyObject DUMP_UNUSED *dump_callback) { switch(ch) { case ST: @@ -1200,7 +1200,7 @@ accumulate_oth(Screen *screen, uint32_t ch, PyObject DUMP_UNUSED *dump_callback) } -static inline bool +static bool accumulate_csi(Screen *screen, uint32_t ch, PyObject DUMP_UNUSED *dump_callback) { #define ENSURE_SPACE \ if (screen->parser_buf_pos > PARSER_BUF_SZ - 1) { \ @@ -1329,14 +1329,14 @@ extern uint32_t *latin1_charset; } \ } -static inline void +static void _parse_bytes(Screen *screen, const uint8_t *buf, Py_ssize_t len, PyObject DUMP_UNUSED *dump_callback) { unsigned int i; decode_loop(dispatch, ;); FLUSH_DRAW; } -static inline size_t +static size_t _parse_bytes_watching_for_pending(Screen *screen, const uint8_t *buf, Py_ssize_t len, PyObject DUMP_UNUSED *dump_callback) { unsigned int i; decode_loop(dispatch, if (screen->pending_mode.activated_at) goto end); diff --git a/kitty/ringbuf.c b/kitty/ringbuf.c index 1588adef5..59420763c 100644 --- a/kitty/ringbuf.c +++ b/kitty/ringbuf.c @@ -26,7 +26,7 @@ #include #include -static inline size_t +static size_t size_t_min(size_t x, size_t y) { return x > y ? y : x; } diff --git a/kitty/screen.c b/kitty/screen.c index 3d69c469b..9b2876941 100644 --- a/kitty/screen.c +++ b/kitty/screen.c @@ -32,14 +32,14 @@ static const ScreenModes empty_modes = {0, .mDECAWM=true, .mDECTCEM=true, .mDECA // Constructor/destructor {{{ -static inline void +static void clear_selection(Selections *selections) { selections->in_progress = false; selections->extend_mode = EXTEND_CELL; selections->count = 0; } -static inline void +static void init_tabstops(bool *tabstops, index_type count) { // In terminfo we specify the number of initial tabstops (it) as 8 for (unsigned int t=0; t < count; t++) { @@ -47,7 +47,7 @@ init_tabstops(bool *tabstops, index_type count) { } } -static inline bool +static bool init_overlay_line(Screen *self, index_type columns) { PyMem_Free(self->overlay_line.cpu_cells); PyMem_Free(self->overlay_line.gpu_cells); @@ -146,7 +146,7 @@ new(PyTypeObject *type, PyObject *args, PyObject UNUSED *kwds) { } static void deactivate_overlay_line(Screen *self); -static inline Line* range_line_(Screen *self, int y); +static Line* range_line_(Screen *self, int y); void screen_reset(Screen *self) { @@ -195,7 +195,7 @@ screen_dirty_sprite_positions(Screen *self) { for (index_type i = 0; i < self->historybuf->count; i++) historybuf_mark_line_dirty(self->historybuf, i); } -static inline HistoryBuf* +static HistoryBuf* realloc_hb(HistoryBuf *old, unsigned int lines, unsigned int columns, ANSIBuf *as_ansi_buf) { HistoryBuf *ans = alloc_historybuf(lines, columns, 0); if (ans == NULL) { PyErr_NoMemory(); return NULL; } @@ -213,7 +213,7 @@ typedef struct CursorTrack { struct { index_type x, y; } temp; } CursorTrack; -static inline LineBuf* +static LineBuf* realloc_lb(LineBuf *old, unsigned int lines, unsigned int columns, index_type *nclb, index_type *ncla, HistoryBuf *hb, CursorTrack *a, CursorTrack *b, ANSIBuf *as_ansi_buf) { LineBuf *ans = alloc_linebuf(lines, columns); if (ans == NULL) { PyErr_NoMemory(); return NULL; } @@ -223,13 +223,13 @@ realloc_lb(LineBuf *old, unsigned int lines, unsigned int columns, index_type *n return ans; } -static inline bool +static bool is_selection_empty(const Selection *s) { int start_y = (int)s->start.y - (int)s->start_scrolled_by, end_y = (int)s->end.y - (int)s->end_scrolled_by; return s->start.x == s->end.x && s->start.in_left_half_of_cell == s->end.in_left_half_of_cell && start_y == end_y; } -static inline void +static void index_selection(const Screen *self, Selections *selections, bool up) { for (size_t i = 0; i < selections->count; i++) { Selection *s = selections->items + i; @@ -423,7 +423,7 @@ screen_designate_charset(Screen *self, uint32_t which, uint32_t as) { } } -static inline void +static void move_widened_char(Screen *self, CPUCell* cpu_cell, GPUCell *gpu_cell, index_type xpos, index_type ypos) { self->cursor->x = xpos; self->cursor->y = ypos; CPUCell src_cpu = *cpu_cell, *dest_cpu; @@ -448,7 +448,7 @@ move_widened_char(Screen *self, CPUCell* cpu_cell, GPUCell *gpu_cell, index_type *dest_gpu = src_gpu; } -static inline bool +static bool selection_has_screen_line(const Selections *selections, const int y) { for (size_t i = 0; i < selections->count; i++) { const Selection *s = selections->items + i; @@ -498,11 +498,11 @@ remap_hyperlink_ids(Screen *self, hyperlink_id_type *map) { } -static inline bool is_flag_pair(char_type a, char_type b) { +static bool is_flag_pair(char_type a, char_type b) { return is_flag_codepoint(a) && is_flag_codepoint(b); } -static inline bool +static bool draw_second_flag_codepoint(Screen *self, char_type ch) { index_type xpos = 0, ypos = 0; if (self->cursor->x > 1) { @@ -523,7 +523,7 @@ draw_second_flag_codepoint(Screen *self, char_type ch) { return true; } -static inline void +static void draw_combining_char(Screen *self, char_type ch) { bool has_prev_char = false; index_type xpos = 0, ypos = 0; @@ -715,12 +715,12 @@ select_graphic_rendition(Screen *self, int *params, unsigned int count, Region * } else cursor_from_sgr(self->cursor, params, count); } -static inline void +static void write_to_test_child(Screen *self, const char *data, size_t sz) { PyObject *r = PyObject_CallMethod(self->test_child, "write", "y#", data, sz); if (r == NULL) PyErr_Print(); Py_CLEAR(r); } -static inline void +static void write_to_child(Screen *self, const char *data, size_t sz) { if (self->window_id) schedule_write_to_child(self->window_id, 1, data, sz); if (self->test_child != Py_None) { write_to_test_child(self, data, sz); } @@ -762,7 +762,7 @@ write_escape_code_to_child(Screen *self, unsigned char which, const char *data) } } -static inline bool +static bool cursor_within_margins(Screen *self) { return self->margin_top <= self->cursor->y && self->cursor->y <= self->margin_bottom; } @@ -1796,20 +1796,20 @@ screen_request_capabilities(Screen *self, char c, PyObject *q) { // }}} // Rendering {{{ -static inline void +static void update_line_data(Line *line, unsigned int dest_y, uint8_t *data) { size_t base = sizeof(GPUCell) * dest_y * line->xnum; memcpy(data + base, line->gpu_cells, line->xnum * sizeof(GPUCell)); } -static inline void +static void screen_reset_dirty(Screen *self) { self->is_dirty = false; self->history_line_added_count = 0; } -static inline bool +static bool screen_has_marker(Screen *self) { return self->marker != NULL; } @@ -1980,7 +1980,7 @@ iteration_data(const Screen *self, const Selection *sel, IterationData *ans, int ans->y = MAX(ans->y, min_y); } -static inline XRange +static XRange xrange_for_iteration(const IterationData *idata, const int y, const Line *line) { XRange ans = {.x_limit=xlimit_for_line(line)}; if (y == idata->y) { @@ -1996,7 +1996,7 @@ xrange_for_iteration(const IterationData *idata, const int y, const Line *line) return ans; } -static inline bool +static bool iteration_data_is_empty(const Screen *self, const IterationData *idata) { if (idata->y >= idata->y_limit) return true; index_type xl = MIN(idata->first.x_limit, self->columns); @@ -2008,7 +2008,7 @@ iteration_data_is_empty(const Screen *self, const IterationData *idata) { return true; } -static inline void +static void apply_selection(Screen *self, uint8_t *data, Selection *s, uint8_t set_mask) { iteration_data(self, s, &s->last_rendered, -self->historybuf->count, true); @@ -2047,7 +2047,7 @@ screen_apply_selection(Screen *self, void *address, size_t size) { self->url_ranges.last_rendered_count = self->url_ranges.count; } -static inline PyObject* +static PyObject* text_for_range(Screen *self, const Selection *sel, bool insert_newlines) { IterationData idata; iteration_data(self, sel, &idata, -self->historybuf->count, false); @@ -2065,7 +2065,7 @@ text_for_range(Screen *self, const Selection *sel, bool insert_newlines) { return ans; } -static inline hyperlink_id_type +static hyperlink_id_type hyperlink_id_for_range(Screen *self, const Selection *sel) { IterationData idata; iteration_data(self, sel, &idata, -self->historybuf->count, false); @@ -2079,7 +2079,7 @@ hyperlink_id_for_range(Screen *self, const Selection *sel) { return 0; } -static inline PyObject* +static PyObject* extend_tuple(PyObject *a, PyObject *b) { Py_ssize_t bs = PyBytes_GET_SIZE(b); if (bs < 1) return a; @@ -2291,7 +2291,7 @@ as_text_non_visual(Screen *self, PyObject *args) { return as_text_generic(args, self, get_range_line, self->lines, &self->as_ansi_buf); } -static inline PyObject* +static PyObject* as_text_generic_wrapper(Screen *self, PyObject *args, get_line_func get_line) { return as_text_generic(args, self, get_line, self->lines, &self->as_ansi_buf); } @@ -2599,7 +2599,7 @@ screen_selection_range_for_line(Screen *self, index_type y, index_type *start, i return true; } -static inline bool +static bool is_opt_word_char(char_type ch) { if (OPT(select_by_word_characters)) { for (const char_type *p = OPT(select_by_word_characters); *p; p++) { @@ -2722,7 +2722,7 @@ screen_start_selection(Screen *self, index_type x, index_type y, bool in_left_ha #undef A } -static inline void +static void add_url_range(Screen *self, index_type start_x, index_type start_y, index_type end_x, index_type end_y) { #define A(attr, val) r->attr = val; ensure_space_for(&self->url_ranges, items, Selection, self->url_ranges.count + 8, capacity, 8, false); @@ -2961,7 +2961,7 @@ send_escape_code_to_child(Screen *self, PyObject *args) { Py_RETURN_NONE; } -static inline void +static void screen_mark_all(Screen *self) { for (index_type y = 0; y < self->main_linebuf->ynum; y++) { linebuf_init_line(self->main_linebuf, y); diff --git a/kitty/shaders.c b/kitty/shaders.c index 60433c328..c5027fd0b 100644 --- a/kitty/shaders.c +++ b/kitty/shaders.c @@ -109,7 +109,7 @@ realloc_sprite_texture(FONTS_DATA_HANDLE fg) { sprite_map->texture_id = tex; } -static inline void +static void ensure_sprite_map(FONTS_DATA_HANDLE fg) { SpriteMap *sprite_map = (SpriteMap*)fg->sprite_map; if (!sprite_map->texture_id) realloc_sprite_texture(fg); @@ -241,7 +241,7 @@ struct CellUniformData { static struct CellUniformData cell_uniform_data = {0, .prev_inactive_text_alpha=-1}; -static inline void +static void send_graphics_data_to_gpu(size_t image_count, ssize_t gvao_idx, const ImageRenderData *render_data) { size_t sz = sizeof(GLfloat) * 16 * image_count; GLfloat *a = alloc_and_map_vao_buffer(gvao_idx, sz, 0, GL_STREAM_DRAW, GL_WRITE_ONLY); @@ -249,7 +249,7 @@ send_graphics_data_to_gpu(size_t image_count, ssize_t gvao_idx, const ImageRende unmap_vao_buffer(gvao_idx, 0); a = NULL; } -static inline void +static void cell_update_uniform_block(ssize_t vao_idx, Screen *screen, int uniform_buffer, GLfloat xstart, GLfloat ystart, GLfloat dx, GLfloat dy, CursorRenderInfo *cursor, bool inverted, OSWindow *os_window) { struct CellRenderData { GLfloat xstart, ystart, dx, dy, sprite_dx, sprite_dy, background_opacity, cursor_text_uses_bg; @@ -306,7 +306,7 @@ cell_update_uniform_block(ssize_t vao_idx, Screen *screen, int uniform_buffer, G unmap_vao_buffer(vao_idx, uniform_buffer); rd = NULL; } -static inline bool +static bool cell_prepare_to_render(ssize_t vao_idx, ssize_t gvao_idx, Screen *screen, GLfloat xstart, GLfloat ystart, GLfloat dx, GLfloat dy, FONTS_DATA_HANDLE fonts_data) { size_t sz; CELL_BUFFERS; @@ -440,7 +440,7 @@ draw_cells_simple(ssize_t vao_idx, ssize_t gvao_idx, Screen *screen) { } } -static inline bool +static bool has_bgimage(OSWindow *w) { return w->bgimage && w->bgimage->texture_id > 0; } @@ -570,7 +570,7 @@ draw_cells_interleaved_premult(ssize_t vao_idx, ssize_t gvao_idx, Screen *screen glDisable(GL_BLEND); } -static inline void +static void set_cell_uniforms(float current_inactive_text_alpha, bool force) { if (!cell_uniform_data.constants_set || force) { cell_uniform_data.gploc = glGetUniformLocation(program_id(GRAPHICS_PROGRAM), "inactive_text_alpha"); diff --git a/kitty/state.c b/kitty/state.c index e65e7b8c9..8e91de0af 100644 --- a/kitty/state.c +++ b/kitty/state.c @@ -196,7 +196,7 @@ add_os_window() { return ans; } -static inline id_type +static id_type add_tab(id_type os_window_id) { WITH_OS_WINDOW(os_window_id) make_os_window_context_current(os_window); @@ -209,13 +209,13 @@ add_tab(id_type os_window_id) { return 0; } -static inline void +static void create_gpu_resources_for_window(Window *w) { w->render_data.vao_idx = create_cell_vao(); w->render_data.gvao_idx = create_graphics_vao(); } -static inline void +static void release_gpu_resources_for_window(Window *w) { if (w->render_data.vao_idx > -1) remove_vao(w->render_data.vao_idx); w->render_data.vao_idx = -1; @@ -223,7 +223,7 @@ release_gpu_resources_for_window(Window *w) { w->render_data.gvao_idx = -1; } -static inline void +static void initialize_window(Window *w, PyObject *title, bool init_gpu_resources) { w->id = ++global_state.window_id_counter; w->visible = true; @@ -236,7 +236,7 @@ initialize_window(Window *w, PyObject *title, bool init_gpu_resources) { } } -static inline id_type +static id_type add_window(id_type os_window_id, id_type tab_id, PyObject *title) { WITH_TAB(os_window_id, tab_id); ensure_space_for(tab, windows, Window, tab->num_windows + 1, capacity, 1, true); @@ -248,7 +248,7 @@ add_window(id_type os_window_id, id_type tab_id, PyObject *title) { return 0; } -static inline void +static void update_window_title(id_type os_window_id, id_type tab_id, id_type window_id, PyObject *title) { WITH_TAB(os_window_id, tab_id); for (size_t i = 0; i < tab->num_windows; i++) { @@ -283,13 +283,13 @@ update_os_window_title(OSWindow *os_window) { } } -static inline void +static void destroy_window(Window *w) { Py_CLEAR(w->render_data.screen); Py_CLEAR(w->title); release_gpu_resources_for_window(w); } -static inline void +static void remove_window_inner(Tab *tab, id_type id) { id_type active_window_id = 0; if (tab->active_window < tab->num_windows) active_window_id = tab->windows[tab->active_window].id; @@ -303,7 +303,7 @@ remove_window_inner(Tab *tab, id_type id) { } } -static inline void +static void remove_window(id_type os_window_id, id_type tab_id, id_type id) { WITH_TAB(os_window_id, tab_id); make_os_window_context_current(osw); @@ -325,7 +325,7 @@ add_detached_window(Window *w) { memcpy(detached_windows.windows + detached_windows.num_windows++, w, sizeof(Window)); } -static inline void +static void detach_window(id_type os_window_id, id_type tab_id, id_type id) { WITH_TAB(os_window_id, tab_id); for (size_t i = 0; i < tab->num_windows; i++) { @@ -342,7 +342,7 @@ detach_window(id_type os_window_id, id_type tab_id, id_type id) { } -static inline void +static void resize_screen(OSWindow *os_window, Screen *screen, bool has_graphics) { if (screen) { screen->cell_size.width = os_window->fonts_data->cell_width; @@ -352,7 +352,7 @@ resize_screen(OSWindow *os_window, Screen *screen, bool has_graphics) { } } -static inline void +static void attach_window(id_type os_window_id, id_type tab_id, id_type id) { WITH_TAB(os_window_id, tab_id); for (size_t i = 0; i < detached_windows.num_windows; i++) { @@ -376,7 +376,7 @@ attach_window(id_type os_window_id, id_type tab_id, id_type id) { END_WITH_TAB; } -static inline void +static void destroy_tab(Tab *tab) { for (size_t i = tab->num_windows; i > 0; i--) remove_window_inner(tab, tab->windows[i - 1].id); remove_vao(tab->border_rects.vao_idx); @@ -384,7 +384,7 @@ destroy_tab(Tab *tab) { free(tab->windows); tab->windows = NULL; } -static inline void +static void remove_tab_inner(OSWindow *os_window, id_type id) { id_type active_tab_id = 0; if (os_window->active_tab < os_window->num_tabs) active_tab_id = os_window->tabs[os_window->active_tab].id; @@ -399,14 +399,14 @@ remove_tab_inner(OSWindow *os_window, id_type id) { } } -static inline void +static void remove_tab(id_type os_window_id, id_type id) { WITH_OS_WINDOW(os_window_id) remove_tab_inner(os_window, id); END_WITH_OS_WINDOW } -static inline void +static void destroy_os_window_item(OSWindow *w) { for (size_t t = w->num_tabs; t > 0; t--) { Tab *tab = w->tabs + t - 1; @@ -439,7 +439,7 @@ remove_os_window(id_type os_window_id) { } -static inline void +static void set_active_tab(id_type os_window_id, unsigned int idx) { WITH_OS_WINDOW(os_window_id) os_window->active_tab = idx; @@ -447,7 +447,7 @@ set_active_tab(id_type os_window_id, unsigned int idx) { END_WITH_OS_WINDOW } -static inline void +static void set_active_window(id_type os_window_id, id_type tab_id, id_type window_id) { WITH_WINDOW(os_window_id, tab_id, window_id) (void)window; @@ -456,7 +456,7 @@ set_active_window(id_type os_window_id, id_type tab_id, id_type window_id) { END_WITH_WINDOW; } -static inline void +static void swap_tabs(id_type os_window_id, unsigned int a, unsigned int b) { WITH_OS_WINDOW(os_window_id) Tab t = os_window->tabs[b]; @@ -650,7 +650,7 @@ static PyStructSequence_Field region_fields[] = { }; static PyStructSequence_Desc region_desc = {"Region", NULL, region_fields, 6}; -static inline PyObject* +static PyObject* wrap_region(Region *r) { PyObject *ans = PyStructSequence_New(&RegionType); if (ans) { @@ -1019,7 +1019,7 @@ pycreate_mock_window(PyObject *self UNUSED, PyObject *args) { return ans; } -static inline void +static void click_mouse_url(id_type os_window_id, id_type tab_id, id_type window_id) { WITH_WINDOW(os_window_id, tab_id, window_id); mouse_open_url(window); diff --git a/launcher.c b/launcher.c index 4b655d69b..51604d4db 100644 --- a/launcher.c +++ b/launcher.c @@ -30,12 +30,12 @@ #define KITTY_LIB_DIR_NAME "lib" #endif -static inline void cleanup_free(void *p) { free(*(void**) p); } +static void cleanup_free(void *p) { free(*(void**) p); } #define FREE_AFTER_FUNCTION __attribute__((cleanup(cleanup_free))) #ifndef __FreeBSD__ -static inline bool +static bool safe_realpath(const char* src, char *buf, size_t buf_sz) { FREE_AFTER_FUNCTION char* ans = realpath(src, NULL); if (ans == NULL) return false; @@ -44,7 +44,7 @@ safe_realpath(const char* src, char *buf, size_t buf_sz) { } #endif -static inline bool +static bool set_xoptions(const char *exe_dir_c, const char *lc_ctype, bool from_source) { wchar_t *exe_dir = Py_DecodeLocale(exe_dir_c, NULL); if (exe_dir == NULL) { fprintf(stderr, "Fatal error: cannot decode exe_dir: %s\n", exe_dir_c); return false; } @@ -199,7 +199,7 @@ run_embedded(const RunData run_data) { // read_exe_path() {{{ #ifdef __APPLE__ -static inline bool +static bool read_exe_path(char *exe, size_t buf_sz) { (void)buf_sz; uint32_t size = PATH_MAX; @@ -212,7 +212,7 @@ read_exe_path(char *exe, size_t buf_sz) { #include #include -static inline bool +static bool read_exe_path(char *exe, size_t buf_sz) { int name[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 }; size_t length = buf_sz; @@ -225,14 +225,14 @@ read_exe_path(char *exe, size_t buf_sz) { } #elif defined(__NetBSD__) -static inline bool +static bool read_exe_path(char *exe, size_t buf_sz) { if (!safe_realpath("/proc/curproc/exe", exe, buf_sz)) { fprintf(stderr, "Failed to read /proc/curproc/exe\n"); return false; } return true; } #elif defined(__OpenBSD__) -static inline bool +static bool read_exe_path(char *exe, size_t buf_sz) { const char *path = getenv("PATH"); if (!path) { fprintf(stderr, "No PATH environment variable set, aborting\n"); return false; } @@ -251,7 +251,7 @@ read_exe_path(char *exe, size_t buf_sz) { #else -static inline bool +static bool read_exe_path(char *exe, size_t buf_sz) { if (!safe_realpath("/proc/self/exe", exe, buf_sz)) { fprintf(stderr, "Failed to read /proc/self/exe\n"); return false; } return true;