unsigned

Gcc: force compiler to use unsigned char by default

让人想犯罪 __ 提交于 2019-12-05 03:14:09
Since the nature of a char in C++ is compiler-dependent when the unsigned qualifier is not present, is there an argument I could pass on to GCC which would force all char s to be compiled as unsigned ? The flag you are looking for is -funsigned-char . From the documentation : -funsigned-char Let the type char be unsigned, like unsigned char . Each kind of machine has a default for what char should be. It is either like unsigned char by default or like signed char by default. Ideally, a portable program should always use signed char or unsigned char when it depends on the signedness of an

How do you get an unsigned long out of a string?

百般思念 提交于 2019-12-05 01:38:12
问题 What's the safest and best way to retrieve an unsigned long from a string in C++? I know of a number of possible methods. First, converting a signed long taken from atol. char *myStr; // Initalized to some value somehow. unsigned long n = ((unsigned)atol(myStr)); The obvious problem with this is, what happens when the value stored in myStr is larger than a signed long can contain? What does atol retrieve? The next possibility is to use strtoul. char *myStr; // Initalized to some value somehow

RPC 远程过程调用协议

主宰稳场 提交于 2019-12-05 00:40:34
远程过程调用协议 编辑 同义词 RPC 一般指远程过程调用协议 RPC(Remote Procedure Call Protocol)—— 远程过程调用 协议,它是一种通过 网络 从远程计算机程序上请求服务,而不需要了解底层网络技术的协议。 RPC协议 假定某些 传输协议 的存在,如TCP或UDP,为通信程序之间携带信息数据。在OSI 网络通信 模型中,RPC跨越了 传输层 和 应用层 。RPC使得开发包括网络 分布式 多程序在内的应用程序更加容易。 RPC采用客户机/服务器模式。请求程序就是一个客户机,而服务提供程序就是一个服务器。首先,客户机调用进程发送一个有进程参数的调用信息到服务进程,然后等待应答信息。在服务器端,进程保持睡眠状态直到调用信息到达为止。当一个调用信息到达,服务器获得进程参数,计算结果,发送答复 信息 ,然后等待下一个调用信息,最后,客户端调用进程接收答复信息,获得进程结果,然后调用执行继续进行。 有多种 RPC模式和执行。最初由 Sun 公司提出。IETF ONC 宪章重新修订了 Sun 版本,使得 ONC RPC 协议成为 IETF 标准协议。现在使用最普遍的模式和执行是开放式软件基础的分布式计算 环境 (DCE)。 中文名 远程过程调用协议 外文名 Remote Procedure Call Protocol 核心思想 信息传输协议 研究方向 分布式

Sword 哈希表

守給你的承諾、 提交于 2019-12-05 00:38:06
哈希表 哈希表是一种典型的以空间换取时间的数据结构,在没有冲突的情况下,对任意元素的插入、索引、删除的时间复杂度都是O(1)。这样优秀的时间复杂度是通过将元素的key值以hash方法f映射到哈希表中的某一个位置来访问记录来实现的,即键值为key的元素必定存储在哈希表中的f(key)的位置。当然,不同的元素的hash值可能相同,这就是hash冲突,有两种解决方法(分离链表发和开放地址发),ngx采用的是开放地址法. 分离链表法是通过将冲突的元素链接在一个哈希表外的一个链表中,这样,找到hash表中的位置后,就可以通过遍历这个单链表来找到这个元素 开放地址法是插入的时候发现自己的位置f(key)已经被占了,就向后遍历,查看f(key)+1的位置是否被占用,如果没被占用,就占用它,否则继续相后,查询的时候,同样也如果f(key)不是需要的值,也依次向后遍历,一直找到需要的元素。 哈希表的本质 普通哈希表的查找比较简单,思想就是先根据hash值找到对应桶,然后遍历这个桶的每一个元素,逐字匹配是否关键字完全相同,完全相同则找到,否则继续,直至找到这个桶的结尾(value = NULL)。 nginx的hash表是固定元素长度的,就是一开始已知所有的键值对。无法动态添加,但是可以修改值 gtc_hash_t * gtc_internal_hash_build(unsigned int max

K60时钟分析

梦想的初衷 提交于 2019-12-04 21:44:38
转载:https://blog.csdn.net/hcx25909/article/details/7164650 1.飞思卡尔K60时钟系统 飞思卡尔K60时钟系统如上图所示,可以发现器件的源时钟源一共有4个: ①内部参考时钟源,包括 Fast IRC和 slow IRC (IRC--Internal Reference Clock) ②外部参考时钟源,只一个EXTAL管脚作为时钟输入,这个可以使用有源晶体振荡器来实现 ③外部晶体谐振器,使用EXTAL和XTAL两个管脚来输入 ④外部32K RTC 谐振器,用于实时时钟的时钟输入 在图中可以看到,要为系统提供时钟信号,关键是要最终生成 MCGOUTCLK 输出。MCGOUTCLK 再经过分频便可以提供Core/system clocks、Bus clock、FlexBus clock和Flash clock。MCGOUTCLK 的产生有3个途径: ①由内部参考时钟源 Fast IRC 直接提供,这个时钟源集成在芯片的内部(包括Slow IRC),频率是2M ②由 FLL 或者 PLL 模块来提供 ③由外部时钟来直接提供,包括外部参考时钟源(1个管脚输入)、外部晶体谐振器经内部OSC logic产生的XTAL_CLK 和 RTC OSC logic 的时钟输出。 一般情况下,MCGOUTCLK 是由PLL或者FLL倍频来产生的

thinkphp 消息队列

故事扮演 提交于 2019-12-04 20:05:58
当前笔记中的内容针对的是 thinkphp-queue 的 v1.1.2 版本,现在官方已经更新到了 v1.1.3 版本, 下文中提到的几个Bug在最新的master分支上均已修复。 笔记中的部分内容还未更新。 传统的程序执行流程一般是 即时|同步|串行的,在某些场景下,会存在并发低,吞吐量低,响应时间长等问题。在大型系统中,一般会引入消息队列的组件,将流程中部分任务抽离出来放入消息队列,并由专门的消费者作针对性的处理,从而降低系统耦合度,提高系统性能和可用性。 一般来说,可以抽离的任务具有以下的特点: 允许延后|异步|并行处理 (相对于传统的 即时|同步|串行 的执行方式) 允许延后: 抢购活动时,先快速缓冲有限的参与人数到消息队列,后续再排队处理实际的抢购业务; 允许异步: 业务处理过程中的邮件,短信等通知 允许并行: 用户支付成功之后,邮件通知,微信通知,短信通知可以由多个不同的消费者并行执行,通知到达的时间不要求先后顺序。 允许失败和重试 强一致性的业务放入核心流程处理 无一致性要求或最终一致即可的业务放入队列处理 thinkphp-queue 是thinkphp 官方提供的一个消息队列服务,它支持消息队列的一些基本特性: 消息的发布,获取,执行,删除,重发,失败处理,延迟执行,超时控制等 队列的多队列, 内存限制 ,启动,停止,守护等 消息队列可降级为同步执行

double precision integer subtraction with 32-bit registers(MIPS)

强颜欢笑 提交于 2019-12-04 18:21:22
I am learning computer arithmetic. The book I use(Patterson and Hennessey) lists the below question. Write mips code to conduct double precision integer subtraction for 64-bit data. Assume the first operand to be in registers $t4(hi) and $t5(lo), second in $t6(hi) and $t7(lo). My solution to the answer is sub $t3, $t5, $t7 # Subtract lo parts of operands. t3 = t5 - t7 sltu $t2, $t5, $t7 # If the lo part of the 1st operand is less than the 2nd, # it means a borrow must be made from the hi part add $t6, $t6, $t2 # Simulate the borrow of the msb-of-low from lsb-of-high sub $t2, $t4, $t6 #

Linux内核定时器

≡放荡痞女 提交于 2019-12-04 12:00:40
1、前言 Linux内核中的定时器是一个很常用的功能,某些需要周期性处理的工作都需要用到定时器。在Linux内核中,使用定时器功能比较简单,需要提供定时器的超时时间和超时后需要执行的处理函数。 2、API接口 在Linux内核中使用全局变量jiffies来记录系统从启动以来的系统节拍数,当系统内核启动的时候,会将该jiffies初始化为0,该定义在文件kernel/include/linux/jiffies.h文件中,如下: extern u64 __jiffy_data jiffies_64; extern unsigned long volatile __jiffy_data jiffies; #if (BITS_PER_LONG < 64) u64 get_jiffies_64(void); #else static inline u64 get_jiffies_64(void) { return (u64)jiffies; } #endif 在上面的代码中,jiffies_64与jiffies变量类似,jiffies_64用于64的系统,而jiffies用于32位系统,Linux内核使用HZ表示每秒的节拍数,使用jiffies/HZ可以获得系统已经运行的时间,单位为秒。 /* time_is_before_jiffies(a) return true if a is

Java 7 unsigned applet permissions 1.7.0_45

馋奶兔 提交于 2019-12-04 11:25:53
We have an applet which requires certain permissions, which we sign and grant all permissions. At development time however we use an unsigned applet. We set all permissions in the user's .java.policy file in their home directory. This has stopped working in 1.7.0_45 (or possibly _40), as the unsigned applet no longer has the extra permissions. We are seeing an error like this: Caused by: java.security.AccessControlException: access denied ("java.util.PropertyPermission" "OurCustomSystemProperty" "read") CAUSE Sun have changed the security behaviour of unsigned applets in 1.7.0_45 or 40. They

How computer distinguish an integer is signed or unsigned?

谁都会走 提交于 2019-12-04 10:40:52
问题 Two's complements is set to make it easier for computer to compute the substraction of two numbers. But how computer distinguish an integer is signed integer or unsigned integer? It's just 0 and 1 in its memory. For exmaple, 1111 1111 in the computer memory may represent number 255 but also can represent -1. 回答1: Signed and unsigned use the same data, but different instructions. The computer stores signed and unsigned integers as the same data. I.e. 255 and -1 are the same bits. However, you