Mercurial > vim
annotate src/os_macosx.m @ 29079:9781c150eddd v8.2.5061
patch 8.2.5061: C89 requires signal handlers to return void
Commit: https://github.com/vim/vim/commit/99c48fe9974b8d70ca33674658a3da722b0d6466
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Jun 5 22:05:19 2022 +0100
patch 8.2.5061: C89 requires signal handlers to return void
Problem: C89 requires signal handlers to return void.
Solution: Drop RETSIGTYPE and hard-code a void return value.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 05 Jun 2022 23:15:02 +0200 |
parents | b90bca860b5a |
children | 24b7e14d55e2 |
rev | line source |
---|---|
10042
4aead6a9b7a9
commit https://github.com/vim/vim/commit/edf3f97ae2af024708ebb4ac614227327033ca47
Christian Brabandt <cb@256bit.org>
parents:
7860
diff
changeset
|
1 /* vi:set ts=8 sts=4 sw=4 noet: |
7 | 2 * |
3 * VIM - Vi IMproved by Bram Moolenaar | |
4 * | |
5 * Do ":help uganda" in Vim to read copying and usage conditions. | |
6 * Do ":help credits" in Vim to see a list of people who contributed. | |
7 * See README.txt for an overview of the Vim source code. | |
8 */ | |
9 | |
10 /* | |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
11 * os_macosx.m -- Mac specific things for Mac OS X. |
7 | 12 */ |
13 | |
13420
f80abb797a32
patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents:
12877
diff
changeset
|
14 /* Suppress compiler warnings to non-C89 code. */ |
f80abb797a32
patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents:
12877
diff
changeset
|
15 #if defined(__clang__) && defined(__STRICT_ANSI__) |
f80abb797a32
patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents:
12877
diff
changeset
|
16 # pragma clang diagnostic push |
f80abb797a32
patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents:
12877
diff
changeset
|
17 # pragma clang diagnostic ignored "-Wc99-extensions" |
f80abb797a32
patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents:
12877
diff
changeset
|
18 # pragma clang diagnostic push |
f80abb797a32
patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents:
12877
diff
changeset
|
19 # pragma clang diagnostic ignored "-Wdeclaration-after-statement" |
f80abb797a32
patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents:
12877
diff
changeset
|
20 #endif |
f80abb797a32
patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents:
12877
diff
changeset
|
21 |
2598 | 22 /* Avoid a conflict for the definition of Boolean between Mac header files and |
23 * X11 header files. */ | |
24 #define NO_X11_INCLUDES | |
25 | |
29071
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
26 #include <stdbool.h> |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
27 #include <mach/boolean.h> |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
28 #include <sys/errno.h> |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
29 #include <stdlib.h> |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
30 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
31 #include <dispatch/dispatch.h> |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
32 |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
33 #include "vim.h" |
12716
351cf7c67bbe
patch 8.0.1236: Mac features are confusing
Christian Brabandt <cb@256bit.org>
parents:
10042
diff
changeset
|
34 #import <AppKit/AppKit.h> |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
35 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
36 |
2565
4b7929dad28a
Fix building the Mac version with GUI.
Bram Moolenaar <bram@vim.org>
parents:
2315
diff
changeset
|
37 /* |
4b7929dad28a
Fix building the Mac version with GUI.
Bram Moolenaar <bram@vim.org>
parents:
2315
diff
changeset
|
38 * Clipboard support for the console. |
4b7929dad28a
Fix building the Mac version with GUI.
Bram Moolenaar <bram@vim.org>
parents:
2315
diff
changeset
|
39 */ |
21785
c346db463a59
patch 8.2.1442: outdated references to the Mac Carbon GUI
Bram Moolenaar <Bram@vim.org>
parents:
21749
diff
changeset
|
40 #if defined(FEAT_CLIPBOARD) |
7 | 41 |
2315 | 42 /* Used to identify clipboard data copied from Vim. */ |
7 | 43 |
2315 | 44 NSString *VimPboardType = @"VimPboardType"; |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
45 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
46 void |
17067
d0438b4b0acf
patch 8.1.1533: GUI build fails on Mac
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
47 clip_mch_lose_selection(Clipboard_T *cbd UNUSED) |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
48 { |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
49 } |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
50 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
51 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
52 int |
17067
d0438b4b0acf
patch 8.1.1533: GUI build fails on Mac
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
53 clip_mch_own_selection(Clipboard_T *cbd UNUSED) |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
54 { |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
55 /* This is called whenever there is a new selection and 'guioptions' |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
56 * contains the "a" flag (automatically copy selection). Return TRUE, else |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
57 * the "a" flag does nothing. Note that there is no concept of "ownership" |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
58 * of the clipboard in Mac OS X. |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
59 */ |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
60 return TRUE; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
61 } |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
62 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
63 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
64 void |
17067
d0438b4b0acf
patch 8.1.1533: GUI build fails on Mac
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
65 clip_mch_request_selection(Clipboard_T *cbd) |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
66 { |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
67 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
68 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
69 NSPasteboard *pb = [NSPasteboard generalPasteboard]; |
14911
73162bc0b21f
patch 8.1.0467: cannot build with Mac OS X 10.5
Bram Moolenaar <Bram@vim.org>
parents:
14091
diff
changeset
|
70 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 |
14091
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
71 NSArray *supportedTypes = [NSArray arrayWithObjects:VimPboardType, |
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
72 NSPasteboardTypeString, nil]; |
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
73 #else |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
74 NSArray *supportedTypes = [NSArray arrayWithObjects:VimPboardType, |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
75 NSStringPboardType, nil]; |
14091
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
76 #endif |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
77 NSString *bestType = [pb availableTypeFromArray:supportedTypes]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
78 if (!bestType) goto releasepool; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
79 |
2909 | 80 int motion_type = MAUTO; |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
81 NSString *string = nil; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
82 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
83 if ([bestType isEqual:VimPboardType]) |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
84 { |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
85 /* This type should consist of an array with two objects: |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
86 * 1. motion type (NSNumber) |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
87 * 2. text (NSString) |
14091
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
88 * If this is not the case we fall back on using NSPasteboardTypeString. |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
89 */ |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
90 id plist = [pb propertyListForType:VimPboardType]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
91 if ([plist isKindOfClass:[NSArray class]] && [plist count] == 2) |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
92 { |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
93 id obj = [plist objectAtIndex:1]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
94 if ([obj isKindOfClass:[NSString class]]) |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
95 { |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
96 motion_type = [[plist objectAtIndex:0] intValue]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
97 string = obj; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
98 } |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
99 } |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
100 } |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
101 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
102 if (!string) |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
103 { |
14091
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
104 /* Use NSPasteboardTypeString. The motion type is detected automatically. |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
105 */ |
14911
73162bc0b21f
patch 8.1.0467: cannot build with Mac OS X 10.5
Bram Moolenaar <Bram@vim.org>
parents:
14091
diff
changeset
|
106 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 |
14091
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
107 NSMutableString *mstring = |
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
108 [[pb stringForType:NSPasteboardTypeString] mutableCopy]; |
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
109 #else |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
110 NSMutableString *mstring = |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
111 [[pb stringForType:NSStringPboardType] mutableCopy]; |
14091
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
112 #endif |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
113 if (!mstring) goto releasepool; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
114 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
115 /* Replace unrecognized end-of-line sequences with \x0a (line feed). */ |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
116 NSRange range = { 0, [mstring length] }; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
117 unsigned n = [mstring replaceOccurrencesOfString:@"\x0d\x0a" |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
118 withString:@"\x0a" options:0 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
119 range:range]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
120 if (0 == n) |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
121 { |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
122 n = [mstring replaceOccurrencesOfString:@"\x0d" withString:@"\x0a" |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
123 options:0 range:range]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
124 } |
2310
3e4574a4b627
Fix a few compiler warnings.
Bram Moolenaar <bram@vim.org>
parents:
2309
diff
changeset
|
125 |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
126 string = mstring; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
127 } |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
128 |
2909 | 129 /* Default to MAUTO, uses MCHAR or MLINE depending on trailing NL. */ |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
130 if (!(MCHAR == motion_type || MLINE == motion_type || MBLOCK == motion_type |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
131 || MAUTO == motion_type)) |
2909 | 132 motion_type = MAUTO; |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
133 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
134 char_u *str = (char_u*)[string UTF8String]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
135 int len = [string lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
136 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
137 if (input_conv.vc_type != CONV_NONE) |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
138 str = string_convert(&input_conv, str, &len); |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
139 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
140 if (str) |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
141 clip_yank_selection(motion_type, str, len, cbd); |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
142 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
143 if (input_conv.vc_type != CONV_NONE) |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
144 vim_free(str); |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
145 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
146 releasepool: |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
147 [pool release]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
148 } |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
149 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
150 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
151 /* |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
152 * Send the current selection to the clipboard. |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
153 */ |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
154 void |
17067
d0438b4b0acf
patch 8.1.1533: GUI build fails on Mac
Bram Moolenaar <Bram@vim.org>
parents:
15607
diff
changeset
|
155 clip_mch_set_selection(Clipboard_T *cbd) |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
156 { |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
157 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
158 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
159 /* If the '*' register isn't already filled in, fill it in now. */ |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
160 cbd->owned = TRUE; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
161 clip_get_selection(cbd); |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
162 cbd->owned = FALSE; |
2310
3e4574a4b627
Fix a few compiler warnings.
Bram Moolenaar <bram@vim.org>
parents:
2309
diff
changeset
|
163 |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
164 /* Get the text to put on the pasteboard. */ |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
165 long_u llen = 0; char_u *str = 0; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
166 int motion_type = clip_convert_selection(&str, &llen, cbd); |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
167 if (motion_type < 0) |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
168 goto releasepool; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
169 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
170 /* TODO: Avoid overflow. */ |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
171 int len = (int)llen; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
172 if (output_conv.vc_type != CONV_NONE) |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
173 { |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
174 char_u *conv_str = string_convert(&output_conv, str, &len); |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
175 if (conv_str) |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
176 { |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
177 vim_free(str); |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
178 str = conv_str; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
179 } |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
180 } |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
181 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
182 if (len > 0) |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
183 { |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
184 NSString *string = [[NSString alloc] |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
185 initWithBytes:str length:len encoding:NSUTF8StringEncoding]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
186 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
187 /* See clip_mch_request_selection() for info on pasteboard types. */ |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
188 NSPasteboard *pb = [NSPasteboard generalPasteboard]; |
14911
73162bc0b21f
patch 8.1.0467: cannot build with Mac OS X 10.5
Bram Moolenaar <Bram@vim.org>
parents:
14091
diff
changeset
|
189 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 |
14091
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
190 NSArray *supportedTypes = [NSArray arrayWithObjects:VimPboardType, |
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
191 NSPasteboardTypeString, nil]; |
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
192 #else |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
193 NSArray *supportedTypes = [NSArray arrayWithObjects:VimPboardType, |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
194 NSStringPboardType, nil]; |
14091
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
195 #endif |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
196 [pb declareTypes:supportedTypes owner:nil]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
197 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
198 NSNumber *motion = [NSNumber numberWithInt:motion_type]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
199 NSArray *plist = [NSArray arrayWithObjects:motion, string, nil]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
200 [pb setPropertyList:plist forType:VimPboardType]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
201 |
14911
73162bc0b21f
patch 8.1.0467: cannot build with Mac OS X 10.5
Bram Moolenaar <Bram@vim.org>
parents:
14091
diff
changeset
|
202 #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 |
14091
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
203 [pb setString:string forType:NSPasteboardTypeString]; |
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
204 #else |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
205 [pb setString:string forType:NSStringPboardType]; |
14091
616dc84228b7
patch 8.1.0063: Mac: NSStringPboardType is deprecated
Christian Brabandt <cb@256bit.org>
parents:
13420
diff
changeset
|
206 #endif |
2310
3e4574a4b627
Fix a few compiler warnings.
Bram Moolenaar <bram@vim.org>
parents:
2309
diff
changeset
|
207 |
2309
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
208 [string release]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
209 } |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
210 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
211 vim_free(str); |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
212 releasepool: |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
213 [pool release]; |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
214 } |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
215 |
543ea69d037f
Add clipboard support in Mac console. (Bjorn Winckler)
Bram Moolenaar <bram@vim.org>
parents:
2215
diff
changeset
|
216 #endif /* FEAT_CLIPBOARD */ |
13420
f80abb797a32
patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents:
12877
diff
changeset
|
217 |
29071
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
218 #ifdef FEAT_RELTIME |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
219 /* |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
220 * The following timer code is based on a Gist by Jorgen Lundman: |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
221 * |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
222 * https://gist.github.com/lundman |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
223 */ |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
224 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
225 typedef struct macos_timer macos_timer_T; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
226 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
227 static void |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
228 _timer_cancel(void *arg UNUSED) |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
229 { |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
230 // This is not currently used, but it might be useful in the future and |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
231 // it is non-trivial enough to provide as usable implementation. |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
232 # if 0 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
233 macos_timer_T *timerid = (macos_timer_T *)arg; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
234 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
235 dispatch_release(timerid->tim_timer); |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
236 dispatch_release(timerid->tim_queue); |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
237 timerid->tim_timer = NULL; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
238 timerid->tim_queue = NULL; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
239 free(timerid); |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
240 # endif |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
241 } |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
242 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
243 static void |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
244 _timer_handler(void *arg) |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
245 { |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
246 macos_timer_T *timerid = (macos_timer_T *)arg; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
247 union sigval sv; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
248 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
249 sv.sival_ptr = timerid->tim_arg; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
250 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
251 if (timerid->tim_func != NULL) |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
252 timerid->tim_func(sv); |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
253 } |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
254 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
255 static uint64_t |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
256 itime_to_ns(const struct timespec *it) |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
257 { |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
258 time_t sec = it->tv_sec; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
259 long nsec = it->tv_nsec; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
260 uint64_t ns = NSEC_PER_SEC * sec + nsec; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
261 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
262 return ns == 0 ? DISPATCH_TIME_FOREVER : ns; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
263 } |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
264 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
265 /* |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
266 * A partial emulation of the POSIX timer_create function. |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
267 * |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
268 * The limitations and differences include: |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
269 * |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
270 * - Only CLOCK_REALTIME and CLOCK_MONOTONIC are supported as clockid |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
271 * values. |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
272 * - Even if CLOCK_REALTIME is specified, internally the mach_absolute_time |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
273 * source is used internally. |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
274 * - The only notification method supported is SIGEV_THREAD. |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
275 */ |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
276 inline int |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
277 timer_create(clockid_t clockid, struct sigevent *sevp, timer_t *timerid) |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
278 { |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
279 macos_timer_T *timer = NULL; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
280 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
281 // We only support real time and monotonic clocks; and SIGEV_THREAD |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
282 // notification. In practice, there is no difference between the two |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
283 // types of clocks on MacOS - we always use the mach_machine_time |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
284 // source. |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
285 if ( (clockid != CLOCK_REALTIME && clockid != CLOCK_MONOTONIC) |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
286 || sevp->sigev_notify != SIGEV_THREAD) |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
287 { |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
288 semsg("clockid: %d %d", clockid, CLOCK_REALTIME); |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
289 semsg("notify: %d %d", sevp->sigev_notify, SIGEV_THREAD); |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
290 errno = ENOTSUP; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
291 return -1; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
292 } |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
293 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
294 timer = (macos_timer_T *)malloc(sizeof(macos_timer_T)); |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
295 if (timer == NULL) |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
296 { |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
297 errno = ENOMEM; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
298 return -1; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
299 } |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
300 *timerid = timer; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
301 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
302 timer->tim_queue = dispatch_queue_create( |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
303 "org.vim.timerqueue", NULL); |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
304 if (timer->tim_queue == NULL) |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
305 { |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
306 errno = ENOMEM; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
307 return -1; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
308 } |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
309 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
310 timer->tim_timer = dispatch_source_create( |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
311 DISPATCH_SOURCE_TYPE_TIMER, 0, 0, timer->tim_queue); |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
312 if (timer->tim_timer == NULL) |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
313 { |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
314 errno = ENOMEM; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
315 return -1; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
316 } |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
317 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
318 timer->tim_func = sevp->sigev_notify_function; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
319 timer->tim_arg = sevp->sigev_value.sival_ptr; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
320 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
321 dispatch_set_context(timer->tim_timer, timer); |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
322 dispatch_source_set_event_handler_f(timer->tim_timer, _timer_handler); |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
323 dispatch_source_set_cancel_handler_f(timer->tim_timer, _timer_cancel); |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
324 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
325 dispatch_resume(timer->tim_timer); |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
326 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
327 return 0; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
328 } |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
329 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
330 /* |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
331 * A partial emulation of the POSIX timer_settime function. |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
332 * |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
333 * The limitations and differences include: |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
334 * |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
335 * - The flags argument is ignored. The supplied new_value is therfore |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
336 * always treated as a relative time. |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
337 * - The old_value argument is ignored. |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
338 */ |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
339 int |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
340 timer_settime( |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
341 timer_t timerid, |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
342 int unused_flags UNUSED, |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
343 const struct itimerspec *new_value, |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
344 struct itimerspec *old_value UNUSED) |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
345 { |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
346 uint64_t first_shot = itime_to_ns(&new_value->it_value); |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
347 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
348 if (timerid == NULL) |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
349 return 0; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
350 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
351 if (first_shot == DISPATCH_TIME_FOREVER) |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
352 { |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
353 dispatch_source_set_timer( |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
354 timerid->tim_timer, first_shot, first_shot, 0); |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
355 } |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
356 else |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
357 { |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
358 uint64_t interval = itime_to_ns(&new_value->it_interval); |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
359 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
360 dispatch_time_t start = dispatch_time(DISPATCH_TIME_NOW, first_shot); |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
361 dispatch_source_set_timer(timerid->tim_timer, start, interval, 0); |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
362 } |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
363 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
364 return 0; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
365 } |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
366 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
367 /* |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
368 * An emulation of the POSIX timer_delete function. |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
369 * |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
370 * Disabled because it is not currently used, but an implemented provided |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
371 * for completeness and possible future use. |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
372 */ |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
373 #if 0 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
374 int |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
375 timer_delete(timer_t timerid) |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
376 { |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
377 /* Calls _timer_cancel() */ |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
378 if (timerid != NULL) |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
379 dispatch_source_cancel(timerid->tim_timer); |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
380 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
381 return 0; |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
382 } |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
383 #endif |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
384 |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
385 #endif /* FEAT_RELTIME */ |
b90bca860b5a
patch 8.2.5057: using gettimeofday() for timeout is very inefficient
Bram Moolenaar <Bram@vim.org>
parents:
21785
diff
changeset
|
386 |
13420
f80abb797a32
patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents:
12877
diff
changeset
|
387 /* Lift the compiler warning suppression. */ |
f80abb797a32
patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents:
12877
diff
changeset
|
388 #if defined(__clang__) && defined(__STRICT_ANSI__) |
f80abb797a32
patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents:
12877
diff
changeset
|
389 # pragma clang diagnostic pop |
f80abb797a32
patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents:
12877
diff
changeset
|
390 # pragma clang diagnostic pop |
f80abb797a32
patch 8.0.1584: using C99 in Mac file gives compiler warning messages
Christian Brabandt <cb@256bit.org>
parents:
12877
diff
changeset
|
391 #endif |