让我们用一个简单的C代码来设置寄存器:
int main()
{
int *a = (int*)111111;
*a = 0x1000;
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当我使用1级优化编译ARM(arm-none-eabi-gcc)代码时,汇编代码如下:
mov r2, #4096
mov r3, #110592
str r2, [r3, #519]
mov r0, #0
bx lr
Run Code Online (Sandbox Code Playgroud)
看起来地址111111被解析为最接近的4K边界(110592)并移动到r3,然后通过将519添加到110592(= 111111)来存储值4096(0x1000).为什么会这样?
在x86中,程序集很简单:
movl $4096, 111111
movl $0, %eax
ret
Run Code Online (Sandbox Code Playgroud) 我注意到嵌入式C中的编程风格,用于固件编程:
#define WRITE_REGISTER(reg, value) \
do { \
write_to_register(reg, value); \
} while (0)
Run Code Online (Sandbox Code Playgroud)
这是怎么做的... while(0)帮助结束:
#define WRITE_REGISTER(reg, value) write_to_register(reg, value)
Run Code Online (Sandbox Code Playgroud) 我正在尝试在Flink中的KeyedStream上执行地图操作:
stream.map(new JsonToMessageObjectMapper())
.keyBy("keyfield")
.map(new MessageProcessorStateful())
Run Code Online (Sandbox Code Playgroud)
JsonToObjectMapper运算符的输出是MessageObject类的POJO,它具有String字段' keyfield '.然后将该流键入此字段.
MessageProcessorStateful是一个RichMapFunction,如下所示:
public class MessageAdProcessorStateful extends RichMapFunction<MessageObject, Tuple2<String, String>> {
private transient MapState<String, Tuple2<Tuple3<String, String, String>, Tuple2<Double, Long>>> state;
...
@Override
public void open(Configuration config) throws Exception {
MapStateDescriptor<String, Tuple2<Tuple3<String, String, String>, Tuple2<Double, Long>>> descriptor =
new MapStateDescriptor<>(
"state", // the state name
TypeInformation.of(new TypeHint<String>() {}),
TypeInformation.of(new TypeHint<Tuple2<Tuple3<String, String, String>, Tuple2<Double, Long>>>() {}) ); // type information
state = getRuntimeContext().getMapState(descriptor);
state.put(...); // Insert a key, value here. Exception here!
} …Run Code Online (Sandbox Code Playgroud) int i=1,2,3,4; // Compile error
// The value of i is 1
int i = (1,2,3,4,5);
// The value of i is 5
Run Code Online (Sandbox Code Playgroud)
C中这些i的定义有什么区别?它们是如何工作的?
编辑:第一个是编译器错误.第二个如何工作?
我明白了 将第一个命令的输出传递给第二个命令的stdin.两个过程如何关联?